home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume20 / pcomm1.2 / part03 < prev    next >
Encoding:
Internet Message Format  |  1989-10-25  |  67.5 KB

  1. Subject:  v20i069:  Pcomm telecommunication package, Part03/08
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: fthood!egray
  7. Posting-number: Volume 20, Issue 69
  8. Archive-name: pcomm1.2/part03
  9.  
  10. #! /bin/sh
  11. # This is a shell archive, meaning:
  12. # 1. Remove everything above the #! /bin/sh line.
  13. # 2. Save the resulting text in a file.
  14. # 3. Execute the file with /bin/sh (not csh) to create:
  15. #    admin.c
  16. #    chg_dir.c
  17. #    config.h
  18. #    curses.c
  19. #    d_delete.c
  20. #    d_lib.c
  21. #    d_manual.c
  22. #    d_menu.c
  23. #    d_print.c
  24. #    d_prompt.c
  25. #    d_revise.c
  26. #    data_log.c
  27. #    di_delay.c
  28. # This archive created: Fri Feb  3 07:35:21 1989
  29. export PATH; PATH=/bin:/usr/bin:$PATH
  30. echo shar: "extracting 'admin.c'" '(2941 characters)'
  31. if test -f 'admin.c'
  32. then
  33.     echo shar: "will not over-write existing file 'admin.c'"
  34. else
  35. sed 's/^X//' << \SHAR_EOF > 'admin.c'
  36. X/*
  37. X * Perform administrative functions.  Check to see if the user has
  38. X * permission to make long distance calls, and record all phone calls
  39. X * made by Pcomm.
  40. X */
  41. X
  42. X#include <stdio.h>
  43. X#include <grp.h>
  44. X#include "config.h"
  45. X#include "dial_dir.h"
  46. X#include "param.h"
  47. X
  48. X/*
  49. X * Make a log of all calls made by Pcomm.  The argument is the index
  50. X * into the queue.
  51. X */
  52. X
  53. X/* ARGSUSED */
  54. Xvoid
  55. Xlog_calls(i)
  56. Xint i;
  57. X{
  58. X#ifdef LOG_CALLS
  59. X    FILE *fp;
  60. X    char *number, *build_num(), *date, *ctime(), *getlogin(), buf[80];
  61. X    long now, time();
  62. X    void error_win();
  63. X                    /* build the complete phone number */
  64. X    number = build_num(i);
  65. X                    /* build date and time */
  66. X    time(&now);
  67. X    date = ctime(&now);
  68. X    date[10] = '\0';
  69. X    date[16] = '\0';
  70. X
  71. X    if (!(fp = fopen(LOGFILE, "a+"))) {
  72. X                    /* fatal! (to prevent hanky panky) */
  73. X        sprintf(buf, "Can't open log file \"%s\"", LOGFILE);
  74. X        error_win(1, buf, "Contact your system administrator");
  75. X    }
  76. X
  77. X    fprintf(fp, "pcomm: %s called %s at %s on %s\n", getlogin(), number, &date[11], date);
  78. X    fclose(fp);
  79. X#endif /* LOG_CALLS */
  80. X    return;
  81. X}
  82. X
  83. X/*
  84. X * Check to see if long distance (toll) call is authorized.  The argument
  85. X * is the index into the queue.
  86. X */
  87. X
  88. X/* ARGSUSED */
  89. Xint
  90. Xlimit_ld(i)
  91. Xint i;
  92. X{
  93. X#ifdef LIMIT_LD
  94. X    char *number, *build_num(), *name, *getlogin();
  95. X    struct group *getgrnam(), *grpbuf;
  96. X
  97. X                    /* if no group, don't bother */
  98. X    grpbuf = getgrnam(GROUP_NAME);
  99. X    if (grpbuf == NULL || *grpbuf->gr_mem == '\0')
  100. X        return(0);
  101. X                    /* are you in the group? */
  102. X    name = getlogin();
  103. X    for (; *grpbuf->gr_mem!='\0'; grpbuf->gr_mem++) {
  104. X        if (!strcmp(*grpbuf->gr_mem, name))
  105. X            return(0);
  106. X    }
  107. X                    /* numbers only... */
  108. X    number = build_num(i);
  109. X
  110. X    /*
  111. X     * VERY SITE SPECIFIC!!!  We use a "9" to get an outside line,
  112. X     * so any 9 followed by a 1 is a toll call (except for 1-800
  113. X     * numbers).
  114. X     */
  115. X    if (!strncmp(number, "91", 2) && strncmp(number, "91800", 5)) {
  116. X        error_win(0, "You are not authorized to place long distance (toll) calls", "");
  117. X        return(1);
  118. X    }
  119. X
  120. X    if (*number == '\0') {
  121. X        error_win(0, "You are not authorized direct access to the line", "Use the automatic dialing feature");
  122. X        return(1);
  123. X    }
  124. X#endif /* LIMIT_LD */
  125. X    return(0);
  126. X}
  127. X
  128. X#if defined(LOG_CALLS) || defined(LIMIT_LD)
  129. X/*
  130. X * Put together the complete phone number but strip out the extraneous
  131. X * characters.
  132. X */
  133. X
  134. Xstatic char *
  135. Xbuild_num(i)
  136. Xint i;
  137. X{
  138. X    int j;
  139. X    char *t, temp[80], *strcpy(), *strcat();
  140. X    static char ans[80];
  141. X
  142. X    temp[0] = '\0';
  143. X                    /* add LD codes? */
  144. X    switch (dir->q_ld[i]) {
  145. X        case 0:
  146. X            break;
  147. X        case '+':
  148. X            strcpy(temp, param->ld_plus);
  149. X            break;
  150. X        case '-':
  151. X            strcpy(temp, param->ld_minus);
  152. X            break;
  153. X        case '@':
  154. X            strcpy(temp, param->ld_at);
  155. X            break;
  156. X        case '#':
  157. X            strcpy(temp, param->ld_pound);
  158. X            break;
  159. X    }
  160. X                    /* add the number */
  161. X    strcat(temp, dir->number[dir->q_num[i]]);
  162. X
  163. X                    /* copy only digits */
  164. X    j = 0;
  165. X    t = temp;
  166. X    while (*t) {
  167. X        if (*t >= '0' && *t <= '9')
  168. X            ans[j++] = *t;
  169. X        t++;
  170. X    }
  171. X    ans[j] = '\0';
  172. X
  173. X    return(ans);
  174. X}
  175. X#endif /* LOG_CALLS || LIMIT_LD */
  176. SHAR_EOF
  177. if test 2941 -ne "`wc -c < 'admin.c'`"
  178. then
  179.     echo shar: "error transmitting 'admin.c'" '(should have been 2941 characters)'
  180. fi
  181. fi
  182. echo shar: "extracting 'chg_dir.c'" '(1514 characters)'
  183. if test -f 'chg_dir.c'
  184. then
  185.     echo shar: "will not over-write existing file 'chg_dir.c'"
  186. else
  187. sed 's/^X//' << \SHAR_EOF > 'chg_dir.c'
  188. X/*
  189. X * Open a window to prompt for a new directory.  Checks to see you have
  190. X * search permission.
  191. X */
  192. X
  193. X#include <curses.h>
  194. X#include "config.h"
  195. X#include "misc.h"
  196. X
  197. Xvoid
  198. Xchg_dir()
  199. X{
  200. X    extern int fd;
  201. X    WINDOW *ch_win, *newwin();
  202. X    char *ans, *dir, *expand(), *cwd, *getcwd(), cwdbuf[200];
  203. X    char *get_str();
  204. X
  205. X    cwd = getcwd(cwdbuf, 200);
  206. X
  207. X    ch_win = newwin(6, 70, 5, 5);
  208. X
  209. X    mvwprintw(ch_win, 2, 4, "Current directory: %s", cwd);
  210. X    mvwaddstr(ch_win, 3, 4, "New directory: ");
  211. X    box(ch_win, VERT, HORZ);
  212. X
  213. X    mvwattrstr(ch_win, 0, 3, A_BOLD, " Change directory ");
  214. X    wmove(ch_win, 3, 19);
  215. X    wrefresh(ch_win);
  216. X                    /* get the answer */
  217. X    while ((ans = get_str(ch_win, 80, "", " \t\n")) != NULL) {
  218. X                    /* a CR means no change */
  219. X        if (*ans == '\0')
  220. X            break;
  221. X                    /* expand the input */
  222. X        dir = expand(ans);
  223. X                    /* if you have search permission */
  224. X        if (!access(dir, 1)) {
  225. X            if (!chdir(dir))
  226. X                break;
  227. X        }
  228. X        beep();
  229. X        mvwattrstr(ch_win, 4, 15, A_BOLD, "No such directory or no access permission");
  230. X        wrefresh(ch_win);
  231. X        wait_key(ch_win, 3);
  232. X                    /* clean up the mess */
  233. X        clear_line(ch_win, 3, 19, TRUE);
  234. X        clear_line(ch_win, 4, 14, TRUE);
  235. X        wmove(ch_win, 3, 19);
  236. X        wrefresh(ch_win);
  237. X    }
  238. X    if (fd == -1) {
  239. X        werase(ch_win);
  240. X        wrefresh(ch_win);
  241. X    }
  242. X    delwin(ch_win);
  243. X    return;
  244. X}
  245. X
  246. X#ifdef BSD
  247. X/*
  248. X * Get the current working directory, AT&T style.  Well... not really, it
  249. X * doesn't handle a NULL pointer for the buffer.
  250. X */
  251. X
  252. X/* ARGSUSED */
  253. Xchar *
  254. Xgetcwd(buf, len)
  255. Xchar *buf;
  256. Xint len;
  257. X{
  258. X    char *getwd();
  259. X
  260. X    return(getwd(buf));
  261. X}
  262. X#endif /* BSD */
  263. SHAR_EOF
  264. if test 1514 -ne "`wc -c < 'chg_dir.c'`"
  265. then
  266.     echo shar: "error transmitting 'chg_dir.c'" '(should have been 1514 characters)'
  267. fi
  268. fi
  269. echo shar: "extracting 'config.h'" '(2286 characters)'
  270. if test -f 'config.h'
  271. then
  272.     echo shar: "will not over-write existing file 'config.h'"
  273. else
  274. sed 's/^X//' << \SHAR_EOF > 'config.h'
  275. X/*
  276. X * Various tunable parameters.  This should appear before any other local
  277. X * header file.
  278. X */
  279. X
  280. X/* Are you using a Berkeley flavor of Unix? */
  281. X#undef    BSD
  282. X
  283. X/* Use the dialing routines specific to the AT&T Unix PC 7300/3b1 */
  284. X#undef    UNIXPC
  285. X
  286. X/* Older versions of curses(3) use termcap in lieu of terminfo */
  287. X#undef    OLDCURSES
  288. X
  289. X/* Use shared memory in lieu of a file for the virtual screen */
  290. X#define    SHAREDMEM
  291. X
  292. X/* Should a missing video attribute be promoted to standout? */
  293. X#define NOPROMOTE
  294. X
  295. X/* Use extra precautions if Pcomm is set-user-id or set-group-id */
  296. X#undef    SETUGID
  297. X
  298. X/* Should Pcomm make a log of all phone calls? */
  299. X#undef    LOG_CALLS
  300. X
  301. X/* The name of the log file (if used).  */
  302. X#define    LOGFILE        "/usr/adm/phone.calls"
  303. X
  304. X/* Should long distance (toll) calls be limited to a specific group? */
  305. X#undef    LIMIT_LD
  306. X
  307. X/* The name of the privileged group for limiting long distance calls */
  308. X#define    GROUP_NAME    "uucp"
  309. X
  310. X/* The path to the line printer program */
  311. X#define    LPR        "lp"
  312. X
  313. X/* The path to the "pretty" printer program (if none, use "pr | lp") */
  314. X#define    LPRINT        "pr | lp"
  315. X
  316. X/* The path to the default directory containing the Pcomm support files */
  317. X#define    DEFAULT_DIR    "/usr/local/lib/pcomm"
  318. X
  319. X/* The path to the directory where UUCP locks are found */
  320. X#define    LOCK_DIR    "/usr/spool/uucp"
  321. X
  322. X/* Do the lock files use ASCII encoded PID's? */
  323. X#undef    ASCII_PID
  324. X
  325. X/* Fold the last character of the lock to lower case? */
  326. X#undef    XENIX_LOCKS
  327. X
  328. X/* Should Pcomm optimize redialing by keeping the TTY port open */
  329. X#define    KEEP_PORT
  330. X
  331. X/* Does the status line scroll up on "magic cookie" terminals? */
  332. X#undef    XMC_BROKE
  333. X
  334. X/* Does the alarm() system call work correctly with the wgetch() function? */
  335. X#undef    WGETCH_BROKE
  336. X
  337. X/* The size of the serial port character buffer */
  338. X#define CLIST_SIZ    64
  339. X
  340. X/* The size of the input buffer (should be about the same as CLIST_SIZ) */
  341. X#define INPUT_BUF    64
  342. X
  343. X/* The size of the output buffer (should be about one half INPUT_BUF) */
  344. X#define OUTPUT_BUF    32
  345. X
  346. X/* Does memmove() exist or is memcpy() well behaved when overlapping? */
  347. X#define MEMMOVE    memcpy
  348. X
  349. X/* Does your Unix allow flip-flop between real and effective user IDs? */
  350. X#undef SETUID_BROKE
  351. X
  352. Xtypedef void SIG_TYPE;
  353. X/* typedef int SIG_TYPE; */
  354. X
  355. X#ifdef BSD
  356. X#define strchr index
  357. X#define strrchr rindex
  358. X#endif /* BSD */
  359. SHAR_EOF
  360. if test 2286 -ne "`wc -c < 'config.h'`"
  361. then
  362.     echo shar: "error transmitting 'config.h'" '(should have been 2286 characters)'
  363. fi
  364. fi
  365. echo shar: "extracting 'curses.c'" '(9053 characters)'
  366. if test -f 'curses.c'
  367. then
  368.     echo shar: "will not over-write existing file 'curses.c'"
  369. else
  370. sed 's/^X//' << \SHAR_EOF > 'curses.c'
  371. X/*
  372. X * Miscellaneous curses(3) routines.
  373. X */
  374. X
  375. X#define STR_WIDTH    256
  376. X#define NUM_WIDTH    16
  377. X
  378. X#include <stdio.h>
  379. X#include <curses.h>
  380. X#include <signal.h>
  381. X#include "config.h"
  382. X#include "misc.h"
  383. X
  384. X#ifdef BSD
  385. X#include <setjmp.h>
  386. Xjmp_buf wk_buf;
  387. X#endif /* BSD */
  388. X
  389. X#ifndef OLDCURSES
  390. X#include <term.h>
  391. X#else /* OLDCURSES */
  392. X#ifdef UNIXPC
  393. X#include <sgtty.h>
  394. X#endif /* UNIXPC */
  395. X#endif /* OLDCURSES */
  396. X
  397. X/*
  398. X * Get a string from a window.  Similar to wgetstr(), except we limit
  399. X * the length, return a NULL (not pointer to NULL) on <ESC> key, beep
  400. X * at any character in "disallow" string, and beep at any character not
  401. X * in "allow". (It doesn't make sense to use both "allow" and "disallow"
  402. X * at the same time).  Returns a pointer to a static area.
  403. X */
  404. X
  405. Xchar *
  406. Xget_str(win, num, allow, disallow)
  407. XWINDOW *win;
  408. Xint num;
  409. Xchar *allow, *disallow;
  410. X{
  411. X    int count, x, y;
  412. X    char ans, *strchr();
  413. X    static char buf[STR_WIDTH];
  414. X
  415. X    count = 0;
  416. X    while ((ans = wgetch(win)) != '\r') {
  417. X                    /* do our own backspace */
  418. X        if (ans == BS || ans == DEL) {
  419. X            if (!count) {
  420. X                beep();
  421. X                continue;
  422. X            }
  423. X            count--;
  424. X            buf[count] = '\0';
  425. X            getyx(win, y, x);
  426. X            x--;
  427. X            wmove(win, y, x);
  428. X            waddch(win, (chtype) ' ');
  429. X            wmove(win, y, x);
  430. X            wrefresh(win);
  431. X            continue;
  432. X        }
  433. X                    /* an <ESC> anywhere in the string */
  434. X        if (ans == ESC)
  435. X            return(NULL);
  436. X
  437. X                    /* illegal character? */
  438. X        if (*disallow != '\0' && strchr(disallow, ans)) {
  439. X            beep();
  440. X            continue;
  441. X        }
  442. X        if (*allow != '\0' && !strchr(allow, ans)) {
  443. X            beep();
  444. X            continue;
  445. X        }
  446. X                    /* exceeded the max? */
  447. X        if (count >= num || count >= STR_WIDTH) {
  448. X            beep();
  449. X            continue;
  450. X        }
  451. X
  452. X        buf[count] = ans;
  453. X        waddch(win, (chtype) ans);
  454. X        wrefresh(win);
  455. X        count++;
  456. X    }
  457. X    buf[count] = '\0';
  458. X    return(buf);
  459. X}
  460. X
  461. X/*
  462. X * Get a number from a window.  We limit the length and return a -1
  463. X * on <ESC> key.
  464. X */
  465. X
  466. Xint
  467. Xget_num(win, num)
  468. XWINDOW *win;
  469. Xint num;
  470. X{
  471. X    int count, x, y, number;
  472. X    char ans, buf[NUM_WIDTH];
  473. X
  474. X    count = 0;
  475. X    while ((ans = wgetch(win)) != '\r') {
  476. X                    /* do our own backspace */
  477. X        if (ans == BS || ans == DEL) {
  478. X            if (!count) {
  479. X                beep();
  480. X                continue;
  481. X            }
  482. X            count--;
  483. X            buf[count] = '\0';
  484. X            getyx(win, y, x);
  485. X            x--;
  486. X            wmove(win, y, x);
  487. X            waddch(win, (chtype) ' ');
  488. X            wmove(win, y, x);
  489. X            wrefresh(win);
  490. X            continue;
  491. X        }
  492. X                    /* an <ESC> anywhere in the string */
  493. X        if (ans == ESC)
  494. X            return(-1);
  495. X                    /* only digits are allowed */
  496. X        if (ans < '0' || ans > '9') {
  497. X            beep();
  498. X            continue;
  499. X        }
  500. X                    /* exceeded the max? */
  501. X        if (count >= num || count >= NUM_WIDTH) {
  502. X            beep();
  503. X            continue;
  504. X        }
  505. X
  506. X        buf[count] = ans;
  507. X        waddch(win, (chtype) ans);
  508. X        wrefresh(win);
  509. X        count++;
  510. X    }
  511. X    buf[count] = '\0';
  512. X    number = atoi(buf);
  513. X    return(number);
  514. X}
  515. X
  516. X/*
  517. X * Change video attributes while printing a string.  The use of the
  518. X * pre-processor definition NOPROMOTE (located in config.h) means that
  519. X * strings will be printed without any special video attribute if the
  520. X * requested capability doesn't exist.
  521. X */
  522. X
  523. Xwattrstr(win, attr, str)
  524. XWINDOW *win;
  525. Xchtype attr;
  526. Xchar *str;
  527. X{
  528. X    int do_it;
  529. X                    /* if nothing, do nothing */
  530. X    if (str == NULL || *str == '\0')
  531. X        return(0);
  532. X
  533. X#ifdef OLDCURSES
  534. X    if (attr)
  535. X        wstandout(win);
  536. X    waddstr(win, str);
  537. X    if (attr)
  538. X        wstandend(win);
  539. X#else /* OLDCURSES */
  540. X
  541. X#ifdef NOPROMOTE
  542. X                    /* does the capability exist? */
  543. X    do_it = 0;
  544. X    if ((attr & A_STANDOUT) && enter_standout_mode)
  545. X        do_it++;
  546. X    if ((attr & A_UNDERLINE) && enter_underline_mode)
  547. X        do_it++;
  548. X    if ((attr & A_REVERSE) && (enter_reverse_mode || enter_standout_mode))
  549. X        do_it++;
  550. X    if ((attr & A_BLINK) && enter_blink_mode)
  551. X        do_it++;
  552. X    if ((attr & A_BOLD) && enter_bold_mode)
  553. X        do_it++;
  554. X    if ((attr & A_DIM) && enter_dim_mode)
  555. X        do_it++;
  556. X#else /* NOPROMOTE */
  557. X    do_it = 1;
  558. X#endif /* NOPROMOTE */
  559. X
  560. X    if (do_it)
  561. X        wattron(win, attr);
  562. X                    /* print the string */
  563. X    waddstr(win, str);
  564. X    if (do_it)
  565. X        wattroff(win, attr);
  566. X#endif /* OLDCURSES */
  567. X    return(0);
  568. X}
  569. X
  570. X/*
  571. X * Change video attributes while printing a character.
  572. X */
  573. X
  574. Xwattrch(win, attr, c)
  575. XWINDOW *win;
  576. Xchtype attr;
  577. Xchar c;
  578. X{
  579. X    int do_it;
  580. X
  581. X    if (c == '\0')
  582. X        return(0);
  583. X#ifdef OLDCURSES
  584. X    if (attr)
  585. X        wstandout(win);
  586. X    waddch(win, (chtype) c);
  587. X    if (attr)
  588. X        wstandend(win);
  589. X#else /* OLDCURSES */
  590. X
  591. X#ifdef NOPROMOTE
  592. X                    /* does the capability exist? */
  593. X    do_it = 0;
  594. X    if ((attr & A_STANDOUT) && enter_standout_mode)
  595. X        do_it++;
  596. X    if ((attr & A_UNDERLINE) && enter_underline_mode)
  597. X        do_it++;
  598. X    if ((attr & A_REVERSE) && (enter_reverse_mode || enter_standout_mode))
  599. X        do_it++;
  600. X    if ((attr & A_BLINK) && enter_blink_mode)
  601. X        do_it++;
  602. X    if ((attr & A_BOLD) && enter_bold_mode)
  603. X        do_it++;
  604. X    if ((attr & A_DIM) && enter_dim_mode)
  605. X        do_it++;
  606. X#else /* NOPROMOTE */
  607. X    do_it = 1;
  608. X#endif /* NOPROMOTE */
  609. X
  610. X    if (do_it)
  611. X        wattron(win, attr);
  612. X                    /* print the character */
  613. X    waddch(win, (chtype) c);
  614. X    if (do_it)
  615. X        wattroff(win, attr);
  616. X#endif /* OLDCURSES */
  617. X    return(0);
  618. X}
  619. X
  620. X
  621. X/*
  622. X * Change video attributes while printing a number.
  623. X */
  624. X
  625. Xwattrnum(win, attr, num)
  626. XWINDOW *win;
  627. Xchtype attr;
  628. Xint num;
  629. X{
  630. X    int do_it;
  631. X    char buf[40];
  632. X
  633. X    sprintf(buf, "%d", num);
  634. X
  635. X#ifdef OLDCURSES
  636. X    if (attr)
  637. X        wstandout(win);
  638. X    waddstr(win, buf);
  639. X    if (attr)
  640. X        wstandend(win);
  641. X#else /* OLDCURSES */
  642. X
  643. X#ifdef NOPROMOTE
  644. X                    /* does the capability exist? */
  645. X    do_it = 0;
  646. X    if ((attr & A_STANDOUT) && enter_standout_mode)
  647. X        do_it++;
  648. X    if ((attr & A_UNDERLINE) && enter_underline_mode)
  649. X        do_it++;
  650. X    if ((attr & A_REVERSE) && (enter_reverse_mode || enter_standout_mode))
  651. X        do_it++;
  652. X    if ((attr & A_BLINK) && enter_blink_mode)
  653. X        do_it++;
  654. X    if ((attr & A_BOLD) && enter_bold_mode)
  655. X        do_it++;
  656. X    if ((attr & A_DIM) && enter_dim_mode)
  657. X        do_it++;
  658. X#else /* NOPROMOTE */
  659. X    do_it = 1;
  660. X#endif /* NOPROMOTE */
  661. X
  662. X    if (do_it)
  663. X        wattron(win, attr);
  664. X                    /* print the character */
  665. X    waddstr(win, buf);
  666. X    if (do_it)
  667. X        wattroff(win, attr);
  668. X#endif /* OLDCURSES */
  669. X    return(0);
  670. X}
  671. X
  672. X/*
  673. X * Prompt for a Yes or No answer.  Echo the single key input as words.
  674. X * Handle the funny cursor movement problems with magic cookie terminals.
  675. X * Returns a 1 on yes.
  676. X */
  677. X
  678. Xint
  679. Xyes_prompt(win, y, x, attr, str)
  680. XWINDOW *win;
  681. Xint y, x;
  682. Xchtype attr;
  683. Xchar *str;
  684. X{
  685. X    int ret_code;
  686. X    char new_str[80], *strcpy(), *strcat();
  687. X                    /* sanity checking */
  688. X    if (strlen(str) > 71)
  689. X        *(str+71) = '\0';
  690. X                    /* build and display the prompt */
  691. X    strcpy(new_str, str);
  692. X    strcat(new_str, "? (y/n):");
  693. X    mvwattrstr(win, y, x, attr, new_str);
  694. X    wmove(win, y, strlen(new_str)+x+2);
  695. X    wrefresh(win);
  696. X
  697. X    ret_code = -1;
  698. X    while (ret_code == -1) {
  699. X        switch (wgetch(win)) {
  700. X            case 'y':
  701. X            case 'Y':
  702. X                waddstr(win, "Yes");
  703. X                ret_code = 1;
  704. X                break;
  705. X            case 'n':
  706. X            case 'N':
  707. X            case ESC:
  708. X                waddstr(win, "No");
  709. X                ret_code = 0;
  710. X                break;
  711. X            default:
  712. X                beep();
  713. X
  714. X        }
  715. X    }
  716. X    wrefresh(win);
  717. X    return(ret_code);
  718. X}
  719. X
  720. X/*
  721. X * Handy routine for clear-to-end-of-line.  Fixes up the box if requested.
  722. X */
  723. X
  724. Xint
  725. Xclear_line(win, y, x, re_box)
  726. XWINDOW *win;
  727. Xint y, x, re_box;
  728. X{
  729. X    if (wmove(win, y, x) == ERR)
  730. X        return(ERR);
  731. X
  732. X    wclrtoeol(win);
  733. X
  734. X    if (re_box) {
  735. X        mvwaddch(win, y, win->_maxx-1, (chtype) ACS_VLINE);
  736. X        wmove(win, y, x);
  737. X    }
  738. X    return(0);
  739. X}
  740. X
  741. X/*
  742. X * Routine to make a horizontal line.  Does NOT do a wrefresh().
  743. X */
  744. X
  745. Xint
  746. Xhorizontal(win, x, y, len)
  747. XWINDOW *win;
  748. Xint x, y, len;
  749. X{
  750. X    wmove(win, x, y);
  751. X
  752. X    while (len--)
  753. X        waddch(win, ACS_HLINE);
  754. X
  755. X    return(0);
  756. X}
  757. X
  758. X/*
  759. X * Wait for a key or time out.  Returns a -1 on timeout.  This is similar
  760. X * to the half-delay mode in the newer versions of curses(3).
  761. X */
  762. X
  763. Xstatic int wk_flag;
  764. X
  765. X/* ARGSUSED */
  766. Xint
  767. Xwait_key(win, sec)
  768. XWINDOW *win;
  769. Xunsigned int sec;
  770. X{
  771. X    int key, wk_force();
  772. X    unsigned int alarm();
  773. X    char c;
  774. X
  775. X    signal(SIGALRM, wk_force);
  776. X    wk_flag = 0;
  777. X
  778. X    alarm(sec);
  779. X
  780. X#ifdef BSD
  781. X    if (setjmp(wk_buf))
  782. X        return(-1);
  783. X#endif /* BSD */
  784. X
  785. X#ifdef WGETCH_BROKE
  786. X    read(0, &c, 1);
  787. X    key = c & 0x7f;
  788. X#else /* WGETCH_BROKE */
  789. X    key = wgetch(win);
  790. X#endif /* WGETCH_BROKE */
  791. X
  792. X    if (wk_flag)
  793. X        return(-1);
  794. X    alarm(0);
  795. X    return(key);
  796. X}
  797. X
  798. X/* ARGSUSED */
  799. Xstatic int
  800. Xwk_force(dummy)
  801. Xint dummy;
  802. X{
  803. X#ifdef BSD
  804. X    longjmp(wk_buf, 1);
  805. X#else /* BSD */
  806. X    signal(SIGALRM, wk_force);
  807. X    wk_flag = 1;
  808. X#endif /* BSD */
  809. X}
  810. X
  811. X/*
  812. X * Here are some routines that are probably missing from the older
  813. X * flavors of curses(3).
  814. X */
  815. X
  816. X#ifdef OLDCURSES
  817. X/*
  818. X * Make the terminal bell go off
  819. X */
  820. X
  821. Xint
  822. Xbeep()
  823. X{
  824. X    fputc(BEL, stderr);
  825. X    return(0);
  826. X}
  827. X
  828. X/*
  829. X * Fix the stdin so that a read is satisfied immediately.  When read()
  830. X * is called it returns the character in the queue, or an error if no
  831. X * key was pressed.  The window argument is not used!
  832. X */
  833. X
  834. X/* ARGSUSED */
  835. Xint
  836. Xnodelay(win, on)
  837. XWINDOW *win;
  838. Xint on;
  839. X{
  840. X    if (on)
  841. X        tty_noblock(0, TRUE);
  842. X    else
  843. X        tty_noblock(0, FALSE);
  844. X    return(0);
  845. X}
  846. X
  847. X/*
  848. X * Take the terminal out of the "curses mode".  The t_mode structure was 
  849. X * captured before we initialized the curses mode.
  850. X */
  851. X
  852. Xint
  853. Xresetterm()
  854. X{
  855. X    extern char _putchar();
  856. X    extern struct sgttyb t_mode;
  857. X
  858. X    ioctl(0, TIOCSETP, &t_mode);
  859. X    tputs(TE, 1, _putchar);
  860. X    tputs(VE, 1, _putchar);
  861. X    return(0);
  862. X}
  863. X
  864. X/*
  865. X * Put the terminal back into the "curses mode".  The c_mode structure was
  866. X * captured after we initialized the curses mode.
  867. X */
  868. X
  869. Xint
  870. Xfixterm()
  871. X{
  872. X    extern char _putchar();
  873. X    extern struct sgttyb c_mode;
  874. X
  875. X    ioctl(0, TIOCSETP, &c_mode);
  876. X    tputs(TI, 1, _putchar);
  877. X    tputs(VS, 1, _putchar);
  878. X    return(0);
  879. X}
  880. X#endif /* OLDCURSES */
  881. SHAR_EOF
  882. if test 9053 -ne "`wc -c < 'curses.c'`"
  883. then
  884.     echo shar: "error transmitting 'curses.c'" '(should have been 9053 characters)'
  885. fi
  886. fi
  887. echo shar: "extracting 'd_delete.c'" '(2015 characters)'
  888. if test -f 'd_delete.c'
  889. then
  890.     echo shar: "will not over-write existing file 'd_delete.c'"
  891. else
  892. sed 's/^X//' << \SHAR_EOF > 'd_delete.c'
  893. X/*
  894. X * The delete option of the dialing directory.  Prompts for saving
  895. X * changes to disk.  A non-zero return code means that entries were deleted.
  896. X */
  897. X
  898. X#include <stdio.h>
  899. X#include <curses.h>
  900. X#include "config.h"
  901. X#include "dial_dir.h"
  902. X#include "misc.h"
  903. X#include "param.h"
  904. X
  905. Xint
  906. Xdelete()
  907. X{
  908. X    extern char *null_ptr;
  909. X    WINDOW *d_win, *newwin();
  910. X    int i, first, last;
  911. X    void free_ptr();
  912. X
  913. X    d_win = newwin(6, 32, 10, 15);
  914. X
  915. X    mvwaddstr(d_win, 2, 2, "Delete entry:     thru:");
  916. X    box(d_win, VERT, HORZ);
  917. X    wmove(d_win, 2, 16);
  918. X    wrefresh(d_win);
  919. X                    /* get the first of the range */
  920. X    while ((first = get_num(d_win, 3)) != -1) {
  921. X        if (first > 0 && first <= NUM_DIR)
  922. X            break;
  923. X        mvwaddstr(d_win, 2, 16, "   ");
  924. X        wmove(d_win, 2, 16);
  925. X        beep();
  926. X        wrefresh(d_win);
  927. X    }
  928. X    if (first == -1) {
  929. X        delwin(d_win);
  930. X        return(0);
  931. X    }
  932. X                    /* get the last of the range */
  933. X    wmove(d_win, 2, 26);
  934. X    wrefresh(d_win);
  935. X    while ((last = get_num(d_win, 3)) != -1) {
  936. X        if ((first <= last && last <= NUM_DIR) || last == 0)
  937. X            break;
  938. X        mvwaddstr(d_win, 2, 26, "   ");
  939. X        wmove(d_win, 2, 26);
  940. X        beep();
  941. X        wrefresh(d_win);
  942. X    }
  943. X    if (last == -1) {
  944. X        delwin(d_win);
  945. X        return(0);
  946. X    }
  947. X                    /* if "last" omitted, echo "first" */
  948. X    if (!last) {
  949. X        last = first;
  950. X        mvwprintw(d_win, 2, 26, "%d", first);
  951. X        wrefresh(d_win);
  952. X    }
  953. X                    /* save to disk? */
  954. X    if (yes_prompt(d_win, 3, 2, A_BOLD, "Are you sure")) {
  955. X                    /* delete from the physical file */
  956. X        if (del_dir(first, last)) {
  957. X            touchwin(d_win);
  958. X            wrefresh(d_win);
  959. X        }
  960. X        /*
  961. X         * We don't really care if del_dir() fails because we still
  962. X         * change the version in memory.
  963. X         */
  964. X        for (i=first; i<=last; i++) {
  965. X            free_ptr(dir->name[i]);
  966. X            free_ptr(dir->number[i]);
  967. X            free_ptr(dir->script[i]);
  968. X            dir->name[i] = null_ptr;
  969. X            dir->number[i] = null_ptr;
  970. X            dir->baud[i] = param->d_baud;
  971. X            dir->parity[i] = param->d_parity;
  972. X            dir->dbits[i] = param->d_dbits;
  973. X            dir->sbits[i] = param->d_sbits;
  974. X            dir->duplex[i] = *param->d_duplex;
  975. X            dir->script[i] = null_ptr;
  976. X        }
  977. X        delwin(d_win);
  978. X        return(1);
  979. X    }
  980. X    delwin(d_win);
  981. X    return(0);
  982. X}
  983. SHAR_EOF
  984. if test 2015 -ne "`wc -c < 'd_delete.c'`"
  985. then
  986.     echo shar: "error transmitting 'd_delete.c'" '(should have been 2015 characters)'
  987. fi
  988. fi
  989. echo shar: "extracting 'd_lib.c'" '(6921 characters)'
  990. if test -f 'd_lib.c'
  991. then
  992.     echo shar: "will not over-write existing file 'd_lib.c'"
  993. else
  994. sed 's/^X//' << \SHAR_EOF > 'd_lib.c'
  995. X/*
  996. X * Routines to manipulate the dialing directory file pcomm.dial_dir
  997. X */
  998. X
  999. X#include <stdio.h>
  1000. X#include "dial_dir.h"
  1001. X#include "param.h"
  1002. X
  1003. X/*
  1004. X * Read the dialing directory.  Returns a pointer to a static area
  1005. X * containing the DIAL_DIR structure.  All of the entries are created
  1006. X * regardless of the number of physical entries in the file.  Element
  1007. X * number zero is reserved for the "manual" entry.  All errors are fatal.
  1008. X */
  1009. X
  1010. Xstruct DIAL_DIR *
  1011. Xread_dir(extra)
  1012. Xchar *extra;
  1013. X{
  1014. X    extern char *null_ptr;
  1015. X    FILE *fp, *my_fopen();
  1016. X    int i, line, oops;
  1017. X    char *str_dup(), buf[200], *temp_token, *str, *str_tok(), token[20];
  1018. X    char message[80], *sep, *findfile();
  1019. X    static struct DIAL_DIR d;
  1020. X    void error_win();
  1021. X
  1022. X    if ((d.d_path = findfile(extra, "pcomm.dial_dir")) == NULL)
  1023. X        error_win(1, "Support file \"pcomm.dial_dir\" is missing", "or no read permission");
  1024. X
  1025. X    if (!(fp = my_fopen(d.d_path, "r"))) {
  1026. X        sprintf(buf, "\"%s\" for read", d.d_path);
  1027. X        error_win(1, "Can't open dialing directory file", buf);
  1028. X    }
  1029. X
  1030. X    sep = ";;---;;\n";
  1031. X    line = 0;
  1032. X    oops = 0;
  1033. X    while (fgets(buf, 200, fp) != NULL) {
  1034. X        line++;
  1035. X        if (line > NUM_DIR)
  1036. X            break;
  1037. X                    /* get the token */
  1038. X        if (!(temp_token = str_tok(buf, '='))) {
  1039. X            sprintf(message, "is missing a token at line %d", line);
  1040. X            oops++;
  1041. X            break;
  1042. X        }
  1043. X        /*
  1044. X         * Parse the rest of the line.  This is similar to using
  1045. X         * the "real" strtok() function, but this version returns
  1046. X         * a pointer to NULL if the token is missing.  Note the use
  1047. X         * of the array of field separators.
  1048. X         */
  1049. X        for (i=0; i<8; i++) {
  1050. X            if (!(str = str_tok((char *) NULL, sep[i]))) {
  1051. X                sprintf(message, "is missing a parameter at line %d", line);
  1052. X                oops++;
  1053. X                break;
  1054. X            }
  1055. X            switch (i) {
  1056. X                case 0:
  1057. X                    d.name[line] = str_dup(str);
  1058. X                    break;
  1059. X                case 1:
  1060. X                    d.number[line] = str_dup(str);
  1061. X                    break;
  1062. X                case 2:
  1063. X                    d.baud[line] = atoi(str);
  1064. X                    break;
  1065. X                case 3:
  1066. X                    d.parity[line] = *str;
  1067. X                    break;
  1068. X                case 4:
  1069. X                    d.dbits[line] = atoi(str);
  1070. X                    break;
  1071. X                case 5:
  1072. X                    d.sbits[line] = atoi(str);
  1073. X                    break;
  1074. X                case 6:
  1075. X                    d.duplex[line] = *str;
  1076. X                    break;
  1077. X                case 7:
  1078. X                    d.script[line] = str_dup(str);
  1079. X                    break;
  1080. X            }
  1081. X        }
  1082. X        if (oops)
  1083. X            break;
  1084. X                    /* sanity checking */
  1085. X        sprintf(token, "DIR_%d", line);
  1086. X        if (strcmp(temp_token, token)) {
  1087. X            sprintf(message, "is corrupted at line %d", line);
  1088. X            oops++;
  1089. X            break;
  1090. X        }
  1091. X    }
  1092. X    fclose(fp);
  1093. X
  1094. X    if (oops) {
  1095. X        sprintf(buf, "Dialing directory file \"%s\"", d.d_path);
  1096. X        error_win(1, buf, message);
  1097. X    }
  1098. X    d.d_entries = line;
  1099. X                    /* if empty database */
  1100. X    if (!line) {
  1101. X        sprintf(buf, "Dialing directory file \"%s\"", d.d_path);
  1102. X        error_win(0, buf, "has no data");
  1103. X    }
  1104. X                    /* fill in the rest with defaults */
  1105. X    for (i=line+1; i<=NUM_DIR; i++) {
  1106. X        d.name[i] = null_ptr;
  1107. X        d.number[i] = null_ptr;
  1108. X        d.baud[i] = param->d_baud;
  1109. X        d.parity[i] = param->d_parity;
  1110. X        d.dbits[i] = param->d_dbits;
  1111. X        d.sbits[i] = param->d_sbits;
  1112. X        d.duplex[i] = *param->d_duplex;
  1113. X        d.script[i] = null_ptr;
  1114. X    }
  1115. X                    /* create an empty "manual" entry */
  1116. X    d.name[0] = null_ptr;
  1117. X    d.number[0] = null_ptr;
  1118. X    d.baud[0] = param->d_baud;
  1119. X    d.parity[0] = param->d_parity;
  1120. X    d.dbits[0] = param->d_dbits;
  1121. X    d.sbits[0] = param->d_sbits;
  1122. X    d.duplex[0] = *param->d_duplex;
  1123. X    d.script[0] = null_ptr;
  1124. X                    /* create an empty queue */
  1125. X    for (i=0; i<NUM_QUEUE; i++) {
  1126. X        d.q_ld[i] = '\0';
  1127. X        d.q_num[i] = -1;
  1128. X    }
  1129. X                    /* the start up d_cur is 0 */
  1130. X    d.d_cur = 0;
  1131. X    return(&d);
  1132. X}
  1133. X
  1134. X/*
  1135. X * Update a dialing directory entry.  Update only the one entry asked for,
  1136. X * not the entire image in memory.  If the new entry is beyond the end of
  1137. X * the physical file, then fill in the holes, and update "dir->d_entries".
  1138. X * A non-zero return code means a non-fatal error.
  1139. X */
  1140. X
  1141. Xint
  1142. Xup_dir(entry)
  1143. Xint entry;
  1144. X{
  1145. X    FILE *fp_in, *fp_out, *my_fopen();
  1146. X    int i;
  1147. X    char *temp[NUM_DIR+1], buf[200], *str_dup(), *str_rep();
  1148. X    void error_win(), free_ptr();
  1149. X
  1150. X                    /* open for read */
  1151. X    if (!(fp_in = my_fopen(dir->d_path, "r"))) {
  1152. X        sprintf(buf, "\"%s\" for read", dir->d_path);
  1153. X        error_win(1, "Can't open dialing directory file", buf);
  1154. X    }
  1155. X                    /* read in a temporary version */
  1156. X    i = 0;
  1157. X    while (fgets(buf, 200, fp_in) != NULL)
  1158. X        temp[++i] = str_dup(buf);
  1159. X
  1160. X    fclose(fp_in);
  1161. X                    /* alter only 1 entry */
  1162. X    sprintf(buf, "DIR_%d=%s;%s;%d-%c-%d-%d;%c;%s\n", entry,
  1163. X     dir->name[entry], dir->number[entry], dir->baud[entry],
  1164. X     dir->parity[entry], dir->dbits[entry], dir->sbits[entry],
  1165. X     dir->duplex[entry], dir->script[entry]);
  1166. X
  1167. X    if (entry <= dir->d_entries)
  1168. X        free_ptr(temp[entry]);
  1169. X    temp[entry] = str_dup(buf);
  1170. X                    /* fill in holes if beyond end */
  1171. X    if (entry > dir->d_entries+1) {
  1172. X        for (i=dir->d_entries+1; i<entry; i++) {
  1173. X            sprintf(buf, "DIR_%d=;;%d-%c-%d-%d;%c;\n", i,
  1174. X             param->d_baud, param->d_parity, param->d_dbits,
  1175. X             param->d_sbits, *param->d_duplex);
  1176. X            temp[i] = str_rep(temp[i], buf);
  1177. X        }
  1178. X    }
  1179. X                    /* update "dir->d_entries" */
  1180. X    if (entry > dir->d_entries)
  1181. X        dir->d_entries = entry;
  1182. X
  1183. X                    /* open for write */
  1184. X    if (!(fp_out = my_fopen(dir->d_path, "w"))) {
  1185. X        for (i=1; i<=dir->d_entries; i++)
  1186. X            free_ptr(temp[i]);
  1187. X        sprintf(buf, "\"%s\"", dir->d_path);
  1188. X        error_win(0, "No write permission on dialing directory file", buf);
  1189. X        return(1);
  1190. X    }
  1191. X                    /* put it back */
  1192. X    for (i=1; i<=dir->d_entries; i++) {
  1193. X        fputs(temp[i], fp_out);
  1194. X        free_ptr(temp[i]);
  1195. X    }
  1196. X
  1197. X    fclose(fp_out);
  1198. X    return(0);
  1199. X}
  1200. X
  1201. X/*
  1202. X * Delete a range of dialing directory entries.  Actually, just copies
  1203. X * default (empty) entries in place of deleted entries.  However, it will
  1204. X * shrink the file if deletions occur at the physical EOF.  A non-zero
  1205. X * return code means a non-fatal error.
  1206. X */
  1207. X
  1208. Xint
  1209. Xdel_dir(first, last)
  1210. Xint first, last;
  1211. X{
  1212. X    FILE *fp_in, *fp_out, *my_fopen();
  1213. X    int i;
  1214. X    char *temp[NUM_DIR+1], buf[200], *str_dup(), *str_rep();
  1215. X    void error_win(), free_ptr();
  1216. X                    /* sanity checking */
  1217. X    if (first > dir->d_entries)
  1218. X        return(0);
  1219. X    if (last > dir->d_entries)
  1220. X        last = dir->d_entries;
  1221. X
  1222. X                    /* open for read */
  1223. X    if (!(fp_in = my_fopen(dir->d_path, "r"))) {
  1224. X        sprintf(buf, "\"%s\" for read", dir->d_path);
  1225. X        error_win(1, "Can't open dialing directory file", buf);
  1226. X    }
  1227. X                    /* read in a temporary version */
  1228. X    i = 0;
  1229. X    while (fgets(buf, 200, fp_in) != NULL)
  1230. X        temp[++i] = str_dup(buf);
  1231. X
  1232. X    fclose(fp_in);
  1233. X                    /* delete the range of values */
  1234. X    for (i=first; i<=last; i++) {
  1235. X        sprintf(buf, "DIR_%d=;;%d-%c-%d-%d;%c;\n", i, param->d_baud,
  1236. X         param->d_parity, param->d_dbits, param->d_sbits,
  1237. X         *param->d_duplex);
  1238. X        temp[i] = str_rep(temp[i], buf);
  1239. X    }
  1240. X                    /* shrink the file? */
  1241. X    if (last >= dir->d_entries) {
  1242. X        for (i=first; i<=last; i++)
  1243. X            free_ptr(temp[i]);
  1244. X        dir->d_entries = first-1;
  1245. X    }
  1246. X                    /* open for write */
  1247. X    if (!(fp_out = my_fopen(dir->d_path, "w"))) {
  1248. X        for (i=1; i<=dir->d_entries; i++)
  1249. X            free_ptr(temp[i]);
  1250. X        sprintf(buf, "\"%s\"", dir->d_path);
  1251. X        error_win(0, "No write permission on dialing directory file", buf);
  1252. X        return(1);
  1253. X    }
  1254. X                    /* put it all back */
  1255. X    for (i=1; i<=dir->d_entries; i++) {
  1256. X        fputs(temp[i], fp_out);
  1257. X        free_ptr(temp[i]);
  1258. X    }
  1259. X
  1260. X    fclose(fp_out);
  1261. X    return(0);
  1262. X}
  1263. SHAR_EOF
  1264. if test 6921 -ne "`wc -c < 'd_lib.c'`"
  1265. then
  1266.     echo shar: "error transmitting 'd_lib.c'" '(should have been 6921 characters)'
  1267. fi
  1268. fi
  1269. echo shar: "extracting 'd_manual.c'" '(1944 characters)'
  1270. if test -f 'd_manual.c'
  1271. then
  1272.     echo shar: "will not over-write existing file 'd_manual.c'"
  1273. else
  1274. sed 's/^X//' << \SHAR_EOF > 'd_manual.c'
  1275. X/*
  1276. X * The manual dial option of the dialing directory.  A non-zero return code
  1277. X * means we're ready to dial.  Dialing directory entry 0 is reserved
  1278. X * for the manual dial option.  No sanity checking is done on the input.
  1279. X */
  1280. X
  1281. X#include <stdio.h>
  1282. X#include <curses.h>
  1283. X#include "config.h"
  1284. X#include "dial_dir.h"
  1285. X#include "misc.h"
  1286. X
  1287. Xint
  1288. Xmanual()
  1289. X{
  1290. X    extern int xmc;
  1291. X    extern char *null_ptr;
  1292. X    WINDOW *m_win, *newwin();
  1293. X    char *number, *str_rep(), *get_str(), ld_code, *strchr();
  1294. X    void fix_xmc(), free_ptr();
  1295. X
  1296. X    m_win = newwin(5, 50, 0, 20);
  1297. X
  1298. X    box(m_win, VERT, HORZ);
  1299. X    mvwaddstr(m_win, 2, 3, "Phone Number: ");
  1300. X    wrefresh(m_win);
  1301. X                    /* get a phone number */
  1302. X    if ((number = get_str(m_win, 30, "", "\n")) == NULL) {
  1303. X        werase(m_win);
  1304. X        wrefresh(m_win);
  1305. X        delwin(m_win);
  1306. X        if (xmc > 0)
  1307. X            fix_xmc();
  1308. X        return(0);
  1309. X    }
  1310. X                    /* is first char an LD code? */
  1311. X    ld_code = '\0';
  1312. X    if (strchr("+-@#", *number)) {
  1313. X        ld_code = *number;
  1314. X        number++;
  1315. X    }
  1316. X                    /* put it in the queue */
  1317. X    dir->q_ld[0] = ld_code;
  1318. X    dir->q_num[0] = 0;
  1319. X                    /* end of queue marker */
  1320. X    dir->q_num[1] = -1;
  1321. X    dir->d_cur = 0;
  1322. X                    /* build the entry zero */
  1323. X    dir->name[0] = str_rep(dir->name[0], number);
  1324. X                    /* if space, change to null_ptr */
  1325. X    if (!strcmp(number, " ")) {
  1326. X        free_ptr(dir->number[0]);
  1327. X        dir->number[0] = null_ptr;
  1328. X    }
  1329. X    else
  1330. X        dir->number[0] = str_rep(dir->number[0], number);
  1331. X                    /* it overlaps dm_win, so erase it */
  1332. X    werase(m_win);
  1333. X    wrefresh(m_win);
  1334. X    delwin(m_win);
  1335. X    if (xmc > 0)
  1336. X        fix_xmc();
  1337. X    return(1);
  1338. X}
  1339. X
  1340. X/*
  1341. X * Clear the end of the physical screen where the magic cookie got shifted
  1342. X * Geez, I hate magic cookie terminals...  Wyse, are you listening?
  1343. X */
  1344. X
  1345. Xstatic void
  1346. Xfix_xmc()
  1347. X{
  1348. X    WINDOW *cl_win, *newwin();
  1349. X
  1350. X    /*
  1351. X     * Since the cookie got shifted off the window, we have to
  1352. X     * create a new window to cover where the cookie ended up.
  1353. X     */
  1354. X    cl_win = newwin(1, 2, 4, 78);
  1355. X                    /* have to touch, otherwise nothing! */
  1356. X    touchwin(cl_win);
  1357. X    wrefresh(cl_win);
  1358. X    delwin(cl_win);
  1359. X
  1360. X    return;
  1361. X}
  1362. SHAR_EOF
  1363. if test 1944 -ne "`wc -c < 'd_manual.c'`"
  1364. then
  1365.     echo shar: "error transmitting 'd_manual.c'" '(should have been 1944 characters)'
  1366. fi
  1367. fi
  1368. echo shar: "extracting 'd_menu.c'" '(6993 characters)'
  1369. if test -f 'd_menu.c'
  1370. then
  1371.     echo shar: "will not over-write existing file 'd_menu.c'"
  1372. else
  1373. sed 's/^X//' << \SHAR_EOF > 'd_menu.c'
  1374. X/*
  1375. X * Routines for the dialing directory menu.
  1376. X */
  1377. X
  1378. X#include <stdio.h>
  1379. X#include <curses.h>
  1380. X#include "config.h"
  1381. X#include "dial_dir.h"
  1382. X#include "misc.h"
  1383. X#include "param.h"
  1384. X
  1385. Xstatic int current = 1;
  1386. X/*
  1387. X * Display the dialing directory and prompt for options.  A non-zero return
  1388. X * code means we're ready to dial.
  1389. X */
  1390. X
  1391. Xint
  1392. Xdial_menu()
  1393. X{
  1394. X    extern int xmc;
  1395. X    WINDOW *dm_win, *newwin();
  1396. X    char buf[5], ld_code;
  1397. X    int ans, start, needs_repair, count, x, y, i, ret_code;
  1398. X    void dir_scroll(), active_ld(), disp_ld(), print_dir(), st_line();
  1399. X
  1400. X    touchwin(stdscr);
  1401. X    refresh();
  1402. X    st_line("");
  1403. X
  1404. X    dm_win = newwin(22, 78, 1, 1);
  1405. X    mvwattrstr(dm_win, 1, 20, A_BOLD, "D I A L I N G       D I R E C T O R Y");
  1406. X    horizontal(dm_win, 2, 0, 78);
  1407. X    mvwattrstr(dm_win, 3, 0, A_STANDOUT, "           Name                   Number        Baud P D S Dpx  Script/TTY    ");
  1408. X                    /* show 10 entries */
  1409. X    dir_scroll(dm_win, current);
  1410. X
  1411. X    mvwaddstr(dm_win, 15, 4, "==>");
  1412. X    mvwattrch(dm_win, 15, 14, A_BOLD, 'R');
  1413. X    waddstr(dm_win, " Revise");
  1414. X    mvwattrch(dm_win, 15, 34, A_BOLD, 'M');
  1415. X    waddstr(dm_win, " Manual Dialing");
  1416. X    mvwaddstr(dm_win, 15, 55, "Entry to Dial");
  1417. X
  1418. X    mvwattrch(dm_win, 16, 14, A_BOLD, 'P');
  1419. X    waddstr(dm_win, " LD Codes");
  1420. X    mvwattrch(dm_win, 16, 34, A_BOLD, 'D');
  1421. X    waddstr(dm_win, " Delete Entry");
  1422. X    mvwattrstr(dm_win, 16, 55, A_BOLD, "<CR>");
  1423. X    waddstr(dm_win, " Scroll Down");
  1424. X
  1425. X    mvwattrstr(dm_win, 17, 14, A_BOLD, "<up>/<down>");
  1426. X    waddstr(dm_win, " Page");
  1427. X    mvwattrch(dm_win, 17, 34, A_BOLD, 'L');
  1428. X    waddstr(dm_win, " Print Entries");
  1429. X    mvwattrstr(dm_win, 17, 55, A_BOLD, "<ESC>");
  1430. X    waddstr(dm_win, " Exit");
  1431. X
  1432. X    mvwaddstr(dm_win, 19, 4, "LD Codes Active:");
  1433. X                    /* show which LD codes are active */
  1434. X    active_ld(dm_win);
  1435. X
  1436. X    box(dm_win, VERT, HORZ);
  1437. X    y = 15;
  1438. X    x = 8;
  1439. X    wmove(dm_win, 15, 8);
  1440. X    wrefresh(dm_win);
  1441. X
  1442. X#ifndef OLDCURSES
  1443. X    keypad(dm_win, TRUE);
  1444. X#endif /* OLDCURSES */
  1445. X                    /* prompt for options */
  1446. X    count = 0;
  1447. X    ld_code = '\0';
  1448. X    ret_code = 0;
  1449. X    do {
  1450. X        needs_repair = 0;
  1451. X        ans = wgetch(dm_win);
  1452. X                    /* get an entry number */
  1453. X        if (ans >= '0' && ans <= '9') {
  1454. X            if (count > 2) {
  1455. X                beep();
  1456. X                continue;
  1457. X            }
  1458. X            buf[count] = ans;
  1459. X            waddch(dm_win, (chtype) ans);
  1460. X            wrefresh(dm_win);
  1461. X            count++;
  1462. X            continue;
  1463. X        }
  1464. X        switch (ans) {
  1465. X            case DEL:
  1466. X            case BS:    /* do our own backspace */
  1467. X                if (!count) {
  1468. X                    beep();
  1469. X                    break;
  1470. X                }
  1471. X                count--;
  1472. X                if (!count)
  1473. X                    ld_code = '\0';
  1474. X                buf[count] = '\0';
  1475. X                getyx(dm_win, y, x);
  1476. X                x--;
  1477. X                wmove(dm_win, y, x);
  1478. X                waddch(dm_win, (chtype) ' ');
  1479. X                wmove(dm_win, y, x);
  1480. X                wrefresh(dm_win);
  1481. X                break;
  1482. X#ifndef OLDCURSES
  1483. X            case KEY_UP:
  1484. X#endif /* OLDCURSES */
  1485. X            case 'u':
  1486. X            case 'U':    /* up arrow key */
  1487. X                if (current == 1) {
  1488. X                    beep();
  1489. X                    break;
  1490. X                }
  1491. X                start = current - 10;
  1492. X                if (start < 1)
  1493. X                    start = 1;
  1494. X                current = start;
  1495. X                dir_scroll(dm_win, start);
  1496. X                break;
  1497. X#ifndef OLDCURSES
  1498. X            case KEY_DOWN:
  1499. X            case '\n':
  1500. X#endif /* OLDCURSES */
  1501. X            case 'n':
  1502. X            case 'N':    /* down arrow key */
  1503. X                if (current == NUM_DIR-9) {
  1504. X                    beep();
  1505. X                    break;
  1506. X                }
  1507. X                start = current + 10;
  1508. X                if (start > NUM_DIR-9)
  1509. X                    start = NUM_DIR-9;
  1510. X                current = start;
  1511. X                dir_scroll(dm_win, start);
  1512. X                break;
  1513. X            case '\r':    /* <CR> key */
  1514. X                if (!count) {
  1515. X                    if (current == NUM_DIR-9) {
  1516. X                        beep();
  1517. X                        break;
  1518. X                    }
  1519. X                    current++;
  1520. X                    if (current > NUM_DIR-9)
  1521. X                        current = NUM_DIR-9;
  1522. X                    dir_scroll(dm_win, current);
  1523. X                }
  1524. X                /*
  1525. X                 * The <CR> is used for the scroll-down-one-line
  1526. X                 * function, and to terminate numeric input.
  1527. X                 */
  1528. X                else {
  1529. X                    buf[count] = '\0';
  1530. X                    i = atoi(buf);
  1531. X                    if (!i || i > NUM_DIR) {
  1532. X                        beep();
  1533. X                        mvwaddstr(dm_win, 15, 8, "   ");
  1534. X                        x = 8;
  1535. X                        count = 0;
  1536. X                        break;
  1537. X                    }
  1538. X                    dir->q_ld[0] = ld_code;
  1539. X                    dir->q_num[0] = i;
  1540. X                    dir->d_cur = i;
  1541. X
  1542. X                    /* end of queue marker */
  1543. X                    dir->q_num[1] = -1;
  1544. X
  1545. X                    ret_code++;
  1546. X                    break;
  1547. X                }
  1548. X                break;
  1549. X            case 'r':
  1550. X            case 'R':    /* revise */
  1551. X                if (revise()) {
  1552. X                    active_ld(dm_win);
  1553. X                    dir_scroll(dm_win, current);
  1554. X                }
  1555. X                touchwin(dm_win);
  1556. X                break;
  1557. X            case 'p':    /* display LD codes */
  1558. X            case 'P':
  1559. X                disp_ld();
  1560. X                touchwin(dm_win);
  1561. X                needs_repair++;
  1562. X                break;
  1563. X            case 'd':
  1564. X            case 'D':    /* delete a range of entries */
  1565. X                if (delete())
  1566. X                    dir_scroll(dm_win, current);
  1567. X                touchwin(dm_win);
  1568. X                break;
  1569. X            case 'm':
  1570. X            case 'M':    /* manual dial */
  1571. X                if (manual()) {
  1572. X                    ret_code++;
  1573. X                    break;
  1574. X                }
  1575. X                touchwin(dm_win);
  1576. X                needs_repair++;
  1577. X                break;
  1578. X            case 'l':
  1579. X            case 'L':    /* print the entries */
  1580. X                print_dir();
  1581. X                touchwin(dm_win);
  1582. X                needs_repair++;
  1583. X                break;
  1584. X            case '+':    /* LD codes */
  1585. X            case '-':
  1586. X            case '@':
  1587. X            case '#':
  1588. X                waddch(dm_win, (chtype) ans);
  1589. X                wrefresh(dm_win);
  1590. X                ld_code = ans;
  1591. X                continue;
  1592. X            case ESC:    /* <ESC> key (exit) */
  1593. X                break;
  1594. X            default:
  1595. X                beep();
  1596. X        }
  1597. X        if (ret_code)
  1598. X            break;
  1599. X                    /* magic cookie terminal? */
  1600. X        if (xmc > 0 && needs_repair) {
  1601. X            clear_line(dm_win, 1, 0, FALSE);
  1602. X            clear_line(dm_win, 3, 0, FALSE);
  1603. X            wrefresh(dm_win);
  1604. X            mvwattrstr(dm_win, 1, 20, A_BOLD, "D I A L I N G       D I R E C T O R Y");
  1605. X            mvwattrstr(dm_win, 3, 0, A_STANDOUT, "           Name                   Number        Baud P D S Dpx  Script/TTY    ");
  1606. X            box(dm_win, VERT, HORZ);
  1607. X        }
  1608. X        wmove(dm_win, y, x);
  1609. X        wrefresh(dm_win);
  1610. X    } while (ans != ESC);
  1611. X
  1612. X    werase(dm_win);
  1613. X    wrefresh(dm_win);
  1614. X    delwin(dm_win);
  1615. X    if (ret_code) {
  1616. X        touchwin(stdscr);
  1617. X        refresh();
  1618. X    }
  1619. X    return(ret_code);
  1620. X}
  1621. X
  1622. X/*
  1623. X * Scroll the dialing directory.  Actually, we're not doing a real scroll
  1624. X * function on the screen, we're just repainting 10 lines.
  1625. X */
  1626. X
  1627. Xstatic void
  1628. Xdir_scroll(win, start)
  1629. XWINDOW *win;
  1630. Xint start;
  1631. X{
  1632. X    int i;
  1633. X
  1634. X    wmove(win, 4, 0);
  1635. X    for (i=start; i<start+10; i++)
  1636. X        wprintw(win,
  1637. X         "%4d- %-20.20s %18.18s  %5d-%c-%d-%d  %c  %-14.14s\n", i,
  1638. X         dir->name[i], dir->number[i], dir->baud[i], dir->parity[i],
  1639. X         dir->dbits[i], dir->sbits[i], dir->duplex[i], dir->script[i]);
  1640. X    box(win, VERT, HORZ);
  1641. X    return;
  1642. X}
  1643. X
  1644. X/*
  1645. X * Display the Long Distance codes.  Press any key to continue.
  1646. X */
  1647. X
  1648. Xstatic void
  1649. Xdisp_ld()
  1650. X{
  1651. X    WINDOW *ld_win, *newwin();
  1652. X
  1653. X    ld_win = newwin(12, 30, 0, 0);
  1654. X    mvwaddstr(ld_win, 1, 5, "Long Distance Codes\n");
  1655. X    horizontal(ld_win, 2, 0, 30);
  1656. X    mvwprintw(ld_win, 3, 2, "+ %-20.20s", param->ld_plus);
  1657. X    mvwprintw(ld_win, 5, 2, "- %-20.20s", param->ld_minus);
  1658. X    mvwprintw(ld_win, 7, 2, "@ %-20.20s", param->ld_at);
  1659. X    mvwprintw(ld_win, 9, 2, "# %-20.20s", param->ld_pound);
  1660. X    box(ld_win, VERT, HORZ);
  1661. X
  1662. X    mvwaddstr(ld_win, 11, 8, " Press any key ");
  1663. X    wmove(ld_win, 11, 29);
  1664. X    wrefresh(ld_win);
  1665. X    wgetch(ld_win);
  1666. X                    /* it overlaps, so erase it */
  1667. X    werase(ld_win);
  1668. X    wrefresh(ld_win);
  1669. X    delwin(ld_win);
  1670. X    return;
  1671. X}
  1672. X
  1673. X/*
  1674. X * Display which of the Long Distance codes are active.
  1675. X */
  1676. X
  1677. Xstatic void
  1678. Xactive_ld(win)
  1679. XWINDOW *win;
  1680. X{
  1681. X    mvwaddstr(win, 19, 21, "        ");
  1682. X    wmove(win, 19, 21);
  1683. X                    /* a NULL means it's not active */
  1684. X    if (*param->ld_plus != '\0')
  1685. X        waddstr(win, "+ ");
  1686. X    if (*param->ld_minus != '\0')
  1687. X        waddstr(win, "- ");
  1688. X    if (*param->ld_at != '\0')
  1689. X        waddstr(win, "@ ");
  1690. X    if (*param->ld_pound != '\0')
  1691. X        waddstr(win, "# ");
  1692. X    return;
  1693. X}
  1694. SHAR_EOF
  1695. if test 6993 -ne "`wc -c < 'd_menu.c'`"
  1696. then
  1697.     echo shar: "error transmitting 'd_menu.c'" '(should have been 6993 characters)'
  1698. fi
  1699. fi
  1700. echo shar: "extracting 'd_print.c'" '(3958 characters)'
  1701. if test -f 'd_print.c'
  1702. then
  1703.     echo shar: "will not over-write existing file 'd_print.c'"
  1704. else
  1705. sed 's/^X//' << \SHAR_EOF > 'd_print.c'
  1706. X/*
  1707. X * The print option of the dialing directory.  A carriage return will
  1708. X * send the dialing directory to the print spool program, otherwise the
  1709. X * selected file will be used.
  1710. X */
  1711. X
  1712. X#define MAX_STRING    80
  1713. X
  1714. X#include <stdio.h>
  1715. X#include <curses.h>
  1716. X#include "config.h"
  1717. X#include "dial_dir.h"
  1718. X#include "misc.h"
  1719. X
  1720. Xvoid
  1721. Xprint_dir()
  1722. X{
  1723. X    FILE *fp, *popen(), *my_fopen();
  1724. X    WINDOW *p_win, *newwin();
  1725. X    char *ans, *file, *e_get_str(), buf[100], *expand();
  1726. X    int is_printer, i;
  1727. X    void error_win();
  1728. X    unsigned int sleep();
  1729. X
  1730. X    p_win = newwin(5, 54, 0, 26);
  1731. X
  1732. X    mvwaddstr(p_win, 2, 3, "Print to: (printer)");
  1733. X    box(p_win, VERT, HORZ);
  1734. X    wmove(p_win, 2, 13);
  1735. X    wrefresh(p_win);
  1736. X
  1737. X    /*
  1738. X     * This is a special version of get_str() that looks at the
  1739. X     * first character to see if it should erase the default answer
  1740. X     * already on the screen.
  1741. X     */
  1742. X    if ((ans = e_get_str(p_win, 80)) == NULL) {
  1743. X                    /* erase because it overlaps dm_win */
  1744. X        werase(p_win);
  1745. X        wrefresh(p_win);
  1746. X        delwin(p_win);
  1747. X        return;
  1748. X    }
  1749. X    file = expand(ans);
  1750. X    is_printer = 0;
  1751. X                    /* the default (printer) */
  1752. X    if (*file == '\0') {
  1753. X        if (!(fp = popen(LPRINT, "w"))) {
  1754. X            sprintf(buf, "\"%s\"", LPRINT);
  1755. X            error_win(0, "Can't open printer program", buf);
  1756. X            werase(p_win);
  1757. X            wrefresh(p_win);
  1758. X            delwin(p_win);
  1759. X            return;
  1760. X        }
  1761. X        is_printer++;
  1762. X    }
  1763. X                    /* the requested file */
  1764. X    else {
  1765. X        /*
  1766. X         * Check to see if the file already exists (and if you
  1767. X         * have write permission too).  Currently only allows
  1768. X         * you to bail out or overwrite the file (no append).
  1769. X         */
  1770. X        switch(can_write(file)) {
  1771. X            case DENIED:
  1772. X                sprintf(buf, "\"%s\"", file);
  1773. X                error_win(0, "No write permission on file", buf);
  1774. X                werase(p_win);
  1775. X                wrefresh(p_win);
  1776. X                delwin(p_win);
  1777. X                return;
  1778. X            case OK_BUT_EXISTS:
  1779. X                werase(p_win);
  1780. X                mvwprintw(p_win, 2, 3, "File \"%s\" already exists!", file);
  1781. X                beep();
  1782. X                box(p_win, VERT, HORZ);
  1783. X                if (!yes_prompt(p_win, 3, 3, A_BOLD, "Overwrite")) {
  1784. X                    werase(p_win);
  1785. X                    wrefresh(p_win);
  1786. X                    delwin(p_win);
  1787. X                    return;
  1788. X                }
  1789. X                /* fall thru */
  1790. X            case WRITE_OK:
  1791. X                if (!(fp = my_fopen(file, "w"))) {
  1792. X                    sprintf(buf, "\"%s\"", file);
  1793. X                    error_win(0, "Can't open file", buf);
  1794. X                    werase(p_win);
  1795. X                    wrefresh(p_win);
  1796. X                    delwin(p_win);
  1797. X                    return;
  1798. X                }
  1799. X                break;
  1800. X        }
  1801. X    }
  1802. X
  1803. X    werase(p_win);
  1804. X    mvwaddstr(p_win, 2, 13, "Printing Pcomm directory");
  1805. X    box(p_win, VERT, HORZ);
  1806. X    wrefresh(p_win);
  1807. X
  1808. X    /*
  1809. X     * Only prints up to the end of the physical file, not the entire
  1810. X     * structure.  I gave some thought about not printing empty entries,
  1811. X     * but...
  1812. X     */
  1813. X    for (i=1; i<=dir->d_entries; i++)
  1814. X        fprintf(fp, "%4d- %-20.20s %18.18s  %5d-%c-%d-%d  %c  %-14.14s\n",
  1815. X         i, dir->name[i], dir->number[i], dir->baud[i], dir->parity[i],
  1816. X         dir->dbits[i], dir->sbits[i], dir->duplex[i], dir->script[i]);
  1817. X
  1818. X    if (is_printer)
  1819. X        pclose(fp);
  1820. X    else {
  1821. X                    /* a dramatic delay... */
  1822. X        sleep(1);
  1823. X        fclose(fp);
  1824. X    }
  1825. X
  1826. X    werase(p_win);
  1827. X    wrefresh(p_win);
  1828. X    delwin(p_win);
  1829. X    return;
  1830. X}
  1831. X
  1832. X/*
  1833. X * Get a string from a window but erase the line first.
  1834. X */
  1835. X
  1836. Xstatic char *
  1837. Xe_get_str(win, num)
  1838. XWINDOW *win;
  1839. Xint num;
  1840. X{
  1841. X    int count, x, y, done_it;
  1842. X    char ans;
  1843. X    static char buf[MAX_STRING];
  1844. X
  1845. X    done_it = 0;
  1846. X    count = 0;
  1847. X    while ((ans = wgetch(win)) != '\r') {
  1848. X                    /* do our own backspace */
  1849. X        if (ans == BS || ans == DEL) {
  1850. X            if (!count) {
  1851. X                beep();
  1852. X                continue;
  1853. X            }
  1854. X            count--;
  1855. X            buf[count] = '\0';
  1856. X            getyx(win, y, x);
  1857. X            x--;
  1858. X            wmove(win, y, x);
  1859. X            waddch(win, (chtype) ' ');
  1860. X            wmove(win, y, x);
  1861. X            wrefresh(win);
  1862. X            continue;
  1863. X        }
  1864. X                    /* exceeded the max? */
  1865. X        if (count >= num || count >= MAX_STRING) {
  1866. X            beep();
  1867. X            continue;
  1868. X        }
  1869. X                    /* illegal character? */
  1870. X        if (ans == '\n') {
  1871. X            beep();
  1872. X            continue;
  1873. X        }
  1874. X                    /* an <ESC> anywhere in the string */
  1875. X        if (ans == ESC)
  1876. X            return(NULL);
  1877. X                    /* erase the default answer */
  1878. X        if (!done_it) {
  1879. X            waddstr(win, "         ");
  1880. X            wmove(win, 2, 13);
  1881. X            wrefresh(win);
  1882. X            done_it++;
  1883. X        }
  1884. X
  1885. X        buf[count] = ans;
  1886. X        waddch(win, (chtype) ans);
  1887. X        wrefresh(win);
  1888. X        count++;
  1889. X    }
  1890. X    buf[count] = '\0';
  1891. X    return(buf);
  1892. X}
  1893. SHAR_EOF
  1894. if test 3958 -ne "`wc -c < 'd_print.c'`"
  1895. then
  1896.     echo shar: "error transmitting 'd_print.c'" '(should have been 3958 characters)'
  1897. fi
  1898. fi
  1899. echo shar: "extracting 'd_prompt.c'" '(6130 characters)'
  1900. if test -f 'd_prompt.c'
  1901. then
  1902.     echo shar: "will not over-write existing file 'd_prompt.c'"
  1903. else
  1904. sed 's/^X//' << \SHAR_EOF > 'd_prompt.c'
  1905. X/*
  1906. X * Prompt for directory entry changes.  Copies the original values in
  1907. X * case you change your mind half way thru.  A non-zero return code means
  1908. X * the entry was changed.
  1909. X */
  1910. X
  1911. X#include <stdio.h>
  1912. X#include <curses.h>
  1913. X#include "config.h"
  1914. X#include "dial_dir.h"
  1915. X#include "misc.h"
  1916. X
  1917. Xint
  1918. Xprompt_lib(win, i)
  1919. XWINDOW *win;
  1920. Xint i;
  1921. X{
  1922. X    extern int xmc;
  1923. X    extern char *null_ptr;
  1924. X    int n, baud, dbits, sbits, spot;
  1925. X    static int valid_baud[6] = {300, 1200, 2400, 4800, 9600, 19200};
  1926. X    static char *valid_parity[3] = {"Even", "Odd", "None"};
  1927. X    char *ans, *get_str(), c, temp, name[40], number[40], script[40];
  1928. X    char parity, duplex, *str_rep(), *strcpy(), buf[40];
  1929. X    void free_ptr();
  1930. X                    /* make copies */
  1931. X    strcpy(name, dir->name[i]);
  1932. X    strcpy(number, dir->number[i]);
  1933. X    baud = dir->baud[i];
  1934. X    parity = dir->parity[i];
  1935. X    dbits = dir->dbits[i];
  1936. X    sbits = dir->sbits[i];
  1937. X    duplex = dir->duplex[i];
  1938. X    strcpy(script, dir->script[i]);
  1939. X                    /* display original values */
  1940. X    werase(win);
  1941. X    mvwprintw(win, 2, 5, "%-20.20s %18.18s  %5d-%c-%d-%d  %c  %-14.14s\n",
  1942. X     dir->name[i], dir->number[i], dir->baud[i], dir->parity[i],
  1943. X     dir->dbits[i], dir->sbits[i], dir->duplex[i], dir->script[i]);
  1944. X    box(win, VERT, HORZ);
  1945. X
  1946. X                    /* prompt for name */
  1947. X    mvwaddstr(win, 4, 4, "Name: ");
  1948. X    wrefresh(win);
  1949. X
  1950. X    if ((ans = get_str(win, 20, "", ";\n")) == NULL)
  1951. X        return(0);
  1952. X    if (*ans != '\0') {
  1953. X        strcpy(name, ans);
  1954. X        mvwaddstr(win, 2, 5, "                    ");
  1955. X        wrefresh(win);
  1956. X        mvwattrstr(win, 2, 5, A_BOLD, name);
  1957. X    }
  1958. X                    /* prompt for number */
  1959. X    clear_line(win, 4, 4, TRUE);
  1960. X    waddstr(win, "Number: ");
  1961. X    wrefresh(win);
  1962. X
  1963. X    if ((ans = get_str(win, 18, "", ";\n")) == NULL)
  1964. X        return(0);
  1965. X    if (*ans != '\0') {
  1966. X        strcpy(number, ans);
  1967. X        mvwaddstr(win, 2, 26, "                  ");
  1968. X        wrefresh(win);
  1969. X        /*
  1970. X         * Should be right justified, but we don't wanna have
  1971. X         * the attribute turned on for blanks.
  1972. X         */
  1973. X        spot = 26 + 18 - strlen(number);
  1974. X        mvwattrstr(win, 2, spot, A_BOLD, number);
  1975. X    }
  1976. X                    /* template for next few */
  1977. X    clear_line(win, 4, 4, TRUE);
  1978. X    mvwaddstr(win, 4, 31, "(Any key to change, <CR> to accept)");
  1979. X
  1980. X    /*
  1981. X     * These next few prompts display a series of choices and allow
  1982. X     * the user to hit <CR> to accept the currently showing value
  1983. X     * or any other key to see the next choice.  The first value
  1984. X     * displayed is always the current value.
  1985. X     */
  1986. X                    /* choose from baud menu */
  1987. X    for (n=0; n<6; n++) {
  1988. X        if (valid_baud[n] == baud)
  1989. X            break;
  1990. X    }
  1991. X    mvwprintw(win, 4, 4, "Baud: %-5d", valid_baud[n]);
  1992. X    wmove(win, 4, 10);
  1993. X    wrefresh(win);
  1994. X
  1995. X    while ((c = wgetch(win)) != '\r') {
  1996. X        if (c == ESC)
  1997. X            return(0);
  1998. X        n = (n == 5) ? 0 : n+1;
  1999. X        mvwprintw(win, 4, 4, "Baud: %-5d", valid_baud[n]);
  2000. X        wmove(win, 4, 10);
  2001. X        wrefresh(win);
  2002. X    }
  2003. X    if (baud != valid_baud[n]) {
  2004. X        baud = valid_baud[n];
  2005. X        sprintf(buf, "%5d", baud);
  2006. X        if (xmc > 0) {
  2007. X            sprintf(buf, "%5d-%c-%d-%d", baud, parity, dbits, sbits);
  2008. X            mvwaddstr(win, 2, 46, "           ");
  2009. X            wrefresh(win);
  2010. X        }
  2011. X        mvwattrstr(win, 2, 46, A_BOLD, buf);
  2012. X    }
  2013. X                    /* choose from parity menu */
  2014. X    for (n=0; n<3; n++) {
  2015. X        if (*valid_parity[n] == parity)
  2016. X            break;
  2017. X    }
  2018. X    mvwprintw(win, 4, 4, "Parity: %-5.5s", valid_parity[n]);
  2019. X    wmove(win, 4, 12);
  2020. X    wrefresh(win);
  2021. X
  2022. X    while ((c = wgetch(win)) != '\r') {
  2023. X        if (c == ESC)
  2024. X            return(0);
  2025. X        n = (n == 2) ? 0 : n+1;
  2026. X        mvwprintw(win, 4, 4, "Parity: %-5.5s", valid_parity[n]);
  2027. X        wmove(win, 4, 12);
  2028. X        wrefresh(win);
  2029. X    }
  2030. X    if (parity != *valid_parity[n]) {
  2031. X        parity = *valid_parity[n];
  2032. X        if (xmc > 0) {
  2033. X            sprintf(buf, "%5d-%c-%d-%d", baud, parity, dbits, sbits);
  2034. X            mvwaddstr(win, 2, 46, "           ");
  2035. X            wrefresh(win);
  2036. X            mvwattrstr(win, 2, 46, A_BOLD, buf);
  2037. X        }
  2038. X        else
  2039. X            mvwattrch(win, 2, 52, A_BOLD, parity);
  2040. X    }
  2041. X                    /* choose from data bits menu */
  2042. X    n = dbits;
  2043. X    mvwprintw(win, 4, 4, "Data Bits: %d    ", n);
  2044. X    wmove(win, 4, 15);
  2045. X    wrefresh(win);
  2046. X
  2047. X    while ((c = wgetch(win)) != '\r') {
  2048. X        if (c == ESC)
  2049. X            return(0);
  2050. X        n = (n == 8) ? 7 : 8;
  2051. X        mvwprintw(win, 4, 4, "Data Bits: %d    ", n);
  2052. X        wmove(win, 4, 15);
  2053. X        wrefresh(win);
  2054. X    }
  2055. X    if (dbits != n) {
  2056. X        dbits = n;
  2057. X        if (xmc > 0) {
  2058. X            sprintf(buf, "%5d-%c-%d-%d", baud, parity, dbits, sbits);
  2059. X            mvwaddstr(win, 2, 46, "           ");
  2060. X            wrefresh(win);
  2061. X            mvwattrstr(win, 2, 46, A_BOLD, buf);
  2062. X        }
  2063. X        else
  2064. X            mvwattrnum(win, 2, 54, A_BOLD, dbits);
  2065. X    }
  2066. X                    /* choose from stop bits menu */
  2067. X    n = sbits;
  2068. X    mvwprintw(win, 4, 4, "Stop Bits: %d    ", n);
  2069. X    wmove(win, 4, 15);
  2070. X    wrefresh(win);
  2071. X
  2072. X    while ((c = wgetch(win)) != '\r') {
  2073. X        if (c == ESC)
  2074. X            return(0);
  2075. X        n = (n == 2) ? 1 : 2;
  2076. X        mvwprintw(win, 4, 4, "Stop Bits: %d    ", n);
  2077. X        wmove(win, 4, 15);
  2078. X        wrefresh(win);
  2079. X    }
  2080. X    if (sbits != n) {
  2081. X        sbits = n;
  2082. X        if (xmc > 0) {
  2083. X            sprintf(buf, "%5d-%c-%d-%d", baud, parity, dbits, sbits);
  2084. X            mvwaddstr(win, 2, 46, "           ");
  2085. X            wrefresh(win);
  2086. X            mvwattrstr(win, 2, 46, A_BOLD, buf);
  2087. X        }
  2088. X        else
  2089. X            mvwattrnum(win, 2, 56, A_BOLD, sbits);
  2090. X    }
  2091. X                    /* choose from duplex menu */
  2092. X    temp = duplex;
  2093. X    mvwprintw(win, 4, 4, "Duplex: %c    ", temp);
  2094. X    wmove(win, 4, 12);
  2095. X    wrefresh(win);
  2096. X
  2097. X    while ((c = wgetch(win)) != '\r') {
  2098. X        if (c == ESC)
  2099. X            return(0);
  2100. X        temp = (temp == 'F') ? 'H' : 'F';
  2101. X        mvwprintw(win, 4, 4, "Duplex: %c    ", temp);
  2102. X        wmove(win, 4, 12);
  2103. X        wrefresh(win);
  2104. X    }
  2105. X    if (duplex != temp) {
  2106. X        duplex = temp;
  2107. X        mvwattrch(win, 2, 59, A_BOLD, duplex);
  2108. X    }
  2109. X                    /* prompt for script or TTY */
  2110. X    clear_line(win, 4, 4, TRUE);
  2111. X    waddstr(win, "Script name (or TTY): ");
  2112. X    wrefresh(win);
  2113. X
  2114. X    if ((ans = get_str(win, 14, "", ";\n")) == NULL)
  2115. X        return(0);
  2116. X
  2117. X    if (*ans != '\0') {
  2118. X        strcpy(script, ans);
  2119. X        mvwaddstr(win, 2, 62, "              ");
  2120. X        wrefresh(win);
  2121. X        mvwattrstr(win, 2, 62, A_BOLD, script);
  2122. X    }
  2123. X                    /* store 'em for real */
  2124. X
  2125. X    if (!strcmp(name, " ")) {
  2126. X        free_ptr(dir->name[i]);
  2127. X        dir->name[i] = null_ptr;
  2128. X    }
  2129. X    else
  2130. X        dir->name[i] = str_rep(dir->name[i], name);
  2131. X
  2132. X    if (!strcmp(number, " ")) {
  2133. X        free_ptr(dir->number[i]);
  2134. X        dir->number[i] = null_ptr;
  2135. X    }
  2136. X    else
  2137. X        dir->number[i] = str_rep(dir->number[i], number);
  2138. X
  2139. X    dir->baud[i] = baud;
  2140. X    dir->parity[i] = parity;
  2141. X    dir->dbits[i] = dbits;
  2142. X    dir->sbits[i] = sbits;
  2143. X    dir->duplex[i] = duplex;
  2144. X
  2145. X    if (!strcmp(script, " ")) {
  2146. X        free_ptr(dir->script[i]);
  2147. X        dir->script[i] = null_ptr;
  2148. X    }
  2149. X    else
  2150. X        dir->script[i] = str_rep(dir->script[i], script);
  2151. X
  2152. X    return(1);
  2153. X}
  2154. SHAR_EOF
  2155. if test 6130 -ne "`wc -c < 'd_prompt.c'`"
  2156. then
  2157.     echo shar: "error transmitting 'd_prompt.c'" '(should have been 6130 characters)'
  2158. fi
  2159. fi
  2160. echo shar: "extracting 'd_revise.c'" '(4009 characters)'
  2161. if test -f 'd_revise.c'
  2162. then
  2163.     echo shar: "will not over-write existing file 'd_revise.c'"
  2164. else
  2165. sed 's/^X//' << \SHAR_EOF > 'd_revise.c'
  2166. X/*
  2167. X * The revise option of the dialing directory.  A non-zero return code
  2168. X * means that something was updated.  Prompts for saving changes to disk.
  2169. X */
  2170. X
  2171. X#include <stdio.h>
  2172. X#include <curses.h>
  2173. X#include "config.h"
  2174. X#include "dial_dir.h"
  2175. X#include "misc.h"
  2176. X#include "param.h"
  2177. X
  2178. Xint
  2179. Xrevise()
  2180. X{
  2181. X    WINDOW *r_win, *newwin();
  2182. X    int count, dir_flag, param_flag, num, x, y, save;
  2183. X    char ans, buf[40], *ld, *ld_prompt(), *str_rep();
  2184. X
  2185. X    r_win = newwin(7, 77, 7, 2);
  2186. X
  2187. X    mvwaddstr(r_win, 3, 6, "Entry to revise?");
  2188. X    mvwaddstr(r_win, 3, 35, "(Entry Number, +, -, @, #)");
  2189. X    box(r_win, VERT, HORZ);
  2190. X    wmove(r_win, 3, 23);
  2191. X    wrefresh(r_win);
  2192. X
  2193. X    dir_flag = 0;
  2194. X    param_flag = 0;
  2195. X    count = 0;
  2196. X
  2197. X    /*
  2198. X     * Can't use my home-grown get_str() and get_num() functions
  2199. X     * here, because we are prompting for an entry number or a
  2200. X     * long distance code.  This routine echoes numbers only.
  2201. X     */
  2202. X    while ((ans = wgetch(r_win)) != ESC) {
  2203. X        if (ans >= '0' && ans <= '9') {
  2204. X            if (count == 3) {
  2205. X                beep();
  2206. X                continue;
  2207. X            }
  2208. X            buf[count] = ans;
  2209. X            waddch(r_win, (chtype) ans);
  2210. X            wrefresh(r_win);
  2211. X            count++;
  2212. X            continue;
  2213. X        }
  2214. X                    /* terminating CR */
  2215. X        if (ans == '\r') {
  2216. X            if (!count) {
  2217. X                beep();
  2218. X                continue;
  2219. X            }
  2220. X            buf[count] = '\0';
  2221. X            num = atoi(buf);
  2222. X                    /* valid range of numbers? */
  2223. X            if (num == 0 || num > NUM_DIR) {
  2224. X                beep();
  2225. X                mvwaddstr(r_win, 3, 23, "   ");
  2226. X                wmove(r_win, 3, 23);
  2227. X                wrefresh(r_win);
  2228. X                count = 0;
  2229. X                continue;
  2230. X            }
  2231. X                    /* prompt for that entry */
  2232. X            if (prompt_lib(r_win, num)) {
  2233. X                dir_flag++;
  2234. X                break;
  2235. X            }
  2236. X            delwin(r_win);
  2237. X            return(0);
  2238. X        }
  2239. X                    /* do our own backspace */
  2240. X        if (ans == BS || ans == DEL) {
  2241. X            if (!count) {
  2242. X                beep();
  2243. X                continue;
  2244. X            }
  2245. X            count--;
  2246. X            buf[count] = '\0';
  2247. X            getyx(r_win, y, x);
  2248. X            x--;
  2249. X            wmove(r_win, y, x);
  2250. X            waddch(r_win, (chtype) ' ');
  2251. X            wmove(r_win, y, x);
  2252. X            wrefresh(r_win);
  2253. X            continue;
  2254. X        }
  2255. X                    /* non-number after number is error */
  2256. X        if (count) {
  2257. X            beep();
  2258. X            continue;
  2259. X        }
  2260. X                    /* prompt for LD codes */
  2261. X        switch (ans) {
  2262. X            case '+':
  2263. X                if ((ld = ld_prompt(r_win, param->ld_plus, ans)) != NULL) {
  2264. X                    param->ld_plus = str_rep(param->ld_plus, ld);
  2265. X                    param_flag++;
  2266. X                }
  2267. X                break;
  2268. X            case '-':
  2269. X                if ((ld = ld_prompt(r_win, param->ld_minus, ans)) != NULL) {
  2270. X                    param->ld_minus = str_rep(param->ld_minus, ld);
  2271. X                    param_flag++;
  2272. X                }
  2273. X                break;
  2274. X            case '@':
  2275. X                if ((ld = ld_prompt(r_win, param->ld_at, ans)) != NULL) {
  2276. X                    param->ld_at = str_rep(param->ld_at, ld);
  2277. X                    param_flag++;
  2278. X                }
  2279. X                break;
  2280. X            case '#':
  2281. X                if ((ld = ld_prompt(r_win, param->ld_pound, ans)) != NULL) {
  2282. X                    param->ld_pound = str_rep(param->ld_pound, ld);
  2283. X                    param_flag++;
  2284. X                }
  2285. X                break;
  2286. X            default:
  2287. X                beep();
  2288. X                continue;
  2289. X        }
  2290. X        break;
  2291. X    }
  2292. X                    /* if nothing changed */
  2293. X    if (!param_flag && !dir_flag) {
  2294. X        delwin(r_win);
  2295. X        return(0);
  2296. X    }
  2297. X                    /* save to disk? */
  2298. X    clear_line(r_win, 4, 4, TRUE);
  2299. X    if (dir_flag) {
  2300. X        sprintf(buf, "Save entry %d to disk", num);
  2301. X        save = yes_prompt(r_win, 4, 4, A_BOLD, buf);
  2302. X    }
  2303. X    else
  2304. X        save = yes_prompt(r_win, 4, 4, A_BOLD, "Save to disk");
  2305. X
  2306. X                    /* update the files */
  2307. X    if (save && dir_flag) {
  2308. X        if (up_dir(num)) {
  2309. X            touchwin(r_win);
  2310. X            wrefresh(r_win);
  2311. X        }
  2312. X    }
  2313. X    if (save && param_flag) {
  2314. X        if (up_param()) {
  2315. X            touchwin(r_win);
  2316. X            wrefresh(r_win);
  2317. X        }
  2318. X    }
  2319. X    delwin(r_win);
  2320. X    return(1);
  2321. X}
  2322. X
  2323. X/*
  2324. X * Prompt for long distance code changes.  If new string is a space,
  2325. X * change it to null_ptr.  Returns NULL on escape.  Since it uses
  2326. X * get_str(), the return value is a pointer to a static area.
  2327. X */
  2328. X
  2329. Xstatic char *
  2330. Xld_prompt(win, current_ld, name)
  2331. XWINDOW *win;
  2332. Xchar *current_ld, name;
  2333. X{
  2334. X    extern char *null_ptr;
  2335. X    char *ans, *get_str();
  2336. X
  2337. X    werase(win);
  2338. X    mvwprintw(win, 2, 4, "%-20.20s", current_ld);
  2339. X    mvwprintw(win, 4, 4, "New LD code for %c: ", name);
  2340. X    box(win, VERT, HORZ);
  2341. X    wrefresh(win);
  2342. X
  2343. X    if ((ans = get_str(win, 20, "", "\n")) == NULL)
  2344. X        return(NULL);
  2345. X                    /* if space, change to null_ptr */
  2346. X    if (!strcmp(ans, " "))
  2347. X        ans = null_ptr;
  2348. X                    /* display new value */
  2349. X    clear_line(win, 2, 4, TRUE);
  2350. X    wattrstr(win, A_BOLD, ans);
  2351. X
  2352. X    return(ans);
  2353. X}
  2354. SHAR_EOF
  2355. if test 4009 -ne "`wc -c < 'd_revise.c'`"
  2356. then
  2357.     echo shar: "error transmitting 'd_revise.c'" '(should have been 4009 characters)'
  2358. fi
  2359. fi
  2360. echo shar: "extracting 'data_log.c'" '(1726 characters)'
  2361. if test -f 'data_log.c'
  2362. then
  2363.     echo shar: "will not over-write existing file 'data_log.c'"
  2364. else
  2365. sed 's/^X//' << \SHAR_EOF > 'data_log.c'
  2366. X/*
  2367. X * Open a window to prompt for a path name to be used for the data logging
  2368. X * feature.  Also turns on the data logging.  A non-zero return code means
  2369. X * we need to restart the input routine.
  2370. X */
  2371. X
  2372. X#include <stdio.h>
  2373. X#include <curses.h>
  2374. X#include "config.h"
  2375. X#include "misc.h"
  2376. X#include "param.h"
  2377. X#include "status.h"
  2378. X
  2379. Xint
  2380. Xdata_logging()
  2381. X{
  2382. X    extern int fd;
  2383. X    int ret_code;
  2384. X    WINDOW *dl_win, *newwin();
  2385. X    char *ans, *path, *expand(), *get_str(), *strcpy();
  2386. X    void input_off();
  2387. X
  2388. X    dl_win = newwin(6, 70, 5, 5);
  2389. X
  2390. X    mvwprintw(dl_win, 2, 4, "Default log file: %s", param->logfile);
  2391. X    mvwaddstr(dl_win, 3, 4, "New log file: ");
  2392. X    box(dl_win, VERT, HORZ);
  2393. X
  2394. X    mvwattrstr(dl_win, 0, 3, A_BOLD, " Start Data Logging ");
  2395. X    wmove(dl_win, 3, 18);
  2396. X    wrefresh(dl_win);
  2397. X                    /* get the path */
  2398. X    ret_code = 0;
  2399. X    while ((ans = get_str(dl_win, PATH, "", " \t\n")) != NULL) {
  2400. X                    /* give 'em the default */
  2401. X        if (*ans == '\0')
  2402. X            path = param->logfile;
  2403. X        else
  2404. X            path = expand(ans);
  2405. X
  2406. X                    /* test write permission */
  2407. X        if (can_write(path)) {
  2408. X            ret_code++;
  2409. X            break;
  2410. X        }
  2411. X
  2412. X        beep();
  2413. X        mvwattrstr(dl_win, 4, 24, A_BOLD, "No write permission");
  2414. X        wrefresh(dl_win);
  2415. X        wait_key(dl_win, 3);
  2416. X                    /* clean up the mess */
  2417. X        clear_line(dl_win, 3, 18, TRUE);
  2418. X        clear_line(dl_win, 4, 24, TRUE);
  2419. X        wmove(dl_win, 3, 18);
  2420. X        wrefresh(dl_win);
  2421. X    }
  2422. X    if (ret_code) {
  2423. X        strcpy(status->log_path, path);
  2424. X        status->log = 1;
  2425. X        /*
  2426. X         * Without shared memory, killing and restarting the input
  2427. X         * routine is the only way to change the name of the file
  2428. X         * that the input routines uses.
  2429. X         */
  2430. X#ifdef SHAREDMEM
  2431. X        ret_code = 0;
  2432. X#else /* SHAREDMEM */
  2433. X        input_off();
  2434. X#endif /* SHAREDMEM */
  2435. X    }
  2436. X    if (fd == -1) {
  2437. X        werase(dl_win);
  2438. X        wrefresh(dl_win);
  2439. X    }
  2440. X    delwin(dl_win);
  2441. X
  2442. X    return(ret_code);
  2443. X}
  2444. SHAR_EOF
  2445. if test 1726 -ne "`wc -c < 'data_log.c'`"
  2446. then
  2447.     echo shar: "error transmitting 'data_log.c'" '(should have been 1726 characters)'
  2448. fi
  2449. fi
  2450. echo shar: "extracting 'di_delay.c'" '(1978 characters)'
  2451. if test -f 'di_delay.c'
  2452. then
  2453.     echo shar: "will not over-write existing file 'di_delay.c'"
  2454. else
  2455. sed 's/^X//' << \SHAR_EOF > 'di_delay.c'
  2456. X/*
  2457. X * Prompt for new delay times during a dialing session.  Also, prompts
  2458. X * if changes should be saved to disk.  Dialing is suspended during
  2459. X * this routine.
  2460. X */
  2461. X
  2462. X#include <stdio.h>
  2463. X#include <curses.h>
  2464. X#include "config.h"
  2465. X#include "misc.h"
  2466. X#include "param.h"
  2467. X
  2468. Xvoid
  2469. Xdelay_times()
  2470. X{
  2471. X    WINDOW *dt_win, *newwin();
  2472. X    int cdelay, rdelay;
  2473. X
  2474. X    dt_win = newwin(9, 45, 7, 15);
  2475. X
  2476. X    mvwprintw(dt_win, 2, 4, "Current connect delay time: %d", param->c_delay);
  2477. X    mvwprintw(dt_win, 3, 4, "Current redial delay time: %d", param->r_delay);
  2478. X    mvwaddstr(dt_win, 5, 4, "New connect delay: ");
  2479. X    mvwaddstr(dt_win, 6, 4, "New redial delay: ");
  2480. X    box(dt_win, VERT, HORZ);
  2481. X
  2482. X    mvwattrstr(dt_win, 0, 3, A_BOLD, " Change delay times ");
  2483. X    wmove(dt_win, 5, 23);
  2484. X    wrefresh(dt_win);
  2485. X                    /* get the cdelay number */
  2486. X    if ((cdelay = get_num(dt_win, 3)) == -1) {
  2487. X        delwin(dt_win);
  2488. X        return;
  2489. X    }
  2490. X                    /* give 'em the current settings */
  2491. X    if (!cdelay) {
  2492. X        cdelay = param->c_delay;
  2493. X        wprintw(dt_win, "%-3d", cdelay);
  2494. X    }
  2495. X    else {
  2496. X                    /* some reasonable limit */
  2497. X        if (cdelay > MAX_CDELAY || cdelay < MIN_CDELAY) {
  2498. X            beep();
  2499. X            if (cdelay > MAX_CDELAY)
  2500. X                cdelay = MAX_CDELAY;
  2501. X            else
  2502. X                cdelay = MIN_CDELAY;
  2503. X            mvwprintw(dt_win, 5, 23, "%-3d", cdelay);
  2504. X        }
  2505. X    }
  2506. X                    /* get the rdelay number */
  2507. X    wmove(dt_win, 6, 20);
  2508. X    wrefresh(dt_win);
  2509. X    if ((rdelay = get_num(dt_win, 3)) == -1) {
  2510. X        delwin(dt_win);
  2511. X        return;
  2512. X    }
  2513. X                    /* give 'em the current settings */
  2514. X    if (!rdelay) {
  2515. X        rdelay = param->r_delay;
  2516. X        wprintw(dt_win, "%-3d", rdelay);
  2517. X    }
  2518. X    else {
  2519. X                    /* some reasonable limit */
  2520. X        if (rdelay > MAX_PAUSE || rdelay < MIN_PAUSE) {
  2521. X            beep();
  2522. X            if (rdelay > MAX_PAUSE)
  2523. X                rdelay = MAX_PAUSE;
  2524. X            else
  2525. X                rdelay = MIN_PAUSE;
  2526. X            mvwprintw(dt_win, 6, 22, "%-3d", rdelay);
  2527. X        }
  2528. X    }
  2529. X                    /* set 'em */
  2530. X    param->c_delay = cdelay;
  2531. X    param->r_delay = rdelay;
  2532. X                    /* save 'em to disk? */
  2533. X    if (yes_prompt(dt_win, 7, 12, A_BOLD, "Save to disk")) {
  2534. X        if (up_param()) {
  2535. X            touchwin(dt_win);
  2536. X            wrefresh(dt_win);
  2537. X        }
  2538. X    }
  2539. X
  2540. X    delwin(dt_win);
  2541. X    return;
  2542. X}
  2543. SHAR_EOF
  2544. if test 1978 -ne "`wc -c < 'di_delay.c'`"
  2545. then
  2546.     echo shar: "error transmitting 'di_delay.c'" '(should have been 1978 characters)'
  2547. fi
  2548. fi
  2549. exit 0
  2550. #    End of shell archive
  2551.  
  2552.  
  2553. From uiucuxc!fthood!egray@uunet.UU.NET Fri May 12 01:10:20 1989
  2554. Received: from uunet.UU.NET by pineapple.bbn.com
  2555.     id <AA10345@pineapple.bbn.com>; Fri, 12 May 89 01:10:06 -0400
  2556. Received: from uiucuxc.UUCP by uunet.UU.NET (5.61/1.14) with UUCP 
  2557.     id AA04432; Fri, 12 May 89 01:10:41 -0400
  2558. From: uiucuxc!fthood!egray@uunet.UU.NET
  2559. Received: from fthood.UUCP by uxc.cso.uiuc.edu with UUCP
  2560.     (5.61+/IDA-1.2.8) id AA00426; Thu, 11 May 89 23:40:56 -0500
  2561. Date: Thu, 11 May 89 23:40:56 -0500
  2562. Message-Id: <8905120440.AA00426@uxc.cso.uiuc.edu>
  2563. To: uiucuxc!pineapple.bbn.com!rsalz@uunet.UU.NET
  2564. Subject: Patch #3 to Pcomm v1.2
  2565. Status: R
  2566.  
  2567. Hello again...
  2568.  
  2569. Some background...  I sent you the source to Pcomm v1.2 back in Feb.
  2570. I've also sent you patch #1 and then patch #2.   This is patch #3...
  2571.  
  2572. I figure I'll keep sending you the patches up to the point when Pcomm
  2573. v1.2 appears in comp.sources.unix, then I'll start sending them to
  2574. comp.sources.bugs.
  2575.  
  2576. Emmet P. Gray                US Army, HQ III Corps & Fort Hood
  2577. ...!uunet!uiucuxc!fthood!egray        Attn: AFZF-DE-ENV
  2578. fthood!egray@uxc.cso.uiuc.edu        Directorate of Engineering & Housing
  2579.                     Environmental Management Office
  2580.                     Fort Hood, TX 76544-5057
  2581.  
  2582. ----------- cut here ------------ cut here ----------- cut here ----------
  2583. Subject: Patch #3 to Pcomm v1.2
  2584.  
  2585. This is patch #3 to the Pcomm v1.2 distribution package.  This patch
  2586. will fix few problems with Pcomm on Microsoft XENIX 3.0/3.5 and changes
  2587. the method of getting rid of zombie processes.
  2588.  
  2589. Emmet P. Gray                US Army, HQ III Corps & Fort Hood
  2590. ...!uunet!uiucuxc!fthood!egray        Attn: AFZF-DE-ENV
  2591.                     Directorate of Engineering & Housing
  2592.                     Environmental Management Office
  2593.                     Fort Hood, TX 76544-5057
  2594. ------------------------------------------------------------------------------
  2595. Prereq: "1.2.2"
  2596. *** old/info.c    Tue Mar  7 11:18:10 1989
  2597. --- info.c    Thu May 11 11:54:25 1989
  2598. ***************
  2599. *** 4,9
  2600.    */
  2601.   
  2602. ! #define VERSION    "1.2.2"
  2603. ! #define DATE    "11 Mar 89"
  2604.   
  2605.   #include <stdio.h>
  2606.  
  2607. --- 4,9 -----
  2608.    */
  2609.   
  2610. ! #define VERSION    "1.2.3"
  2611. ! #define DATE    "11 May 89"
  2612.   
  2613.   #include <stdio.h>
  2614. *** old/Makefile    Fri Feb  3 07:39:32 1989
  2615. --- Makefile    Thu May 11 11:53:47 1989
  2616. ***************
  2617. *** 8,11
  2618.   #TERMLIB = -ltinfo -lx
  2619.   
  2620.   CFLAGS = -O
  2621.   LDFLAGS = -s
  2622.  
  2623. --- 8,15 -----
  2624.   #TERMLIB = -ltinfo -lx
  2625.   
  2626. + #for 80286 versions of Microsoft Xenix 3.0/3.5
  2627. + #CFLAGS = -O -Mme2 -Dresetterm=xresetterm -DXENIX_3
  2628. + #LDFLAGS = -s -Mm -F 5120
  2629.   CFLAGS = -O
  2630.   LDFLAGS = -s
  2631. ***************
  2632. *** 63,71
  2633.       cp matches $(BIN)
  2634.       cp modem_break $(BIN)
  2635. ! #    rm pcomm
  2636. ! #    rm pcomm_input
  2637. ! #    rm waitfor
  2638. ! #    rm matches
  2639. ! #    rm modem_break
  2640.   
  2641.   lint:
  2642.  
  2643. --- 67,77 -----
  2644.       cp matches $(BIN)
  2645.       cp modem_break $(BIN)
  2646. ! clean:
  2647. !     rm pcomm
  2648. !     rm pcomm_input
  2649. !     rm waitfor
  2650. !     rm matches
  2651. !     rm modem_break
  2652.   
  2653.   lint:
  2654. *** old/d_menu.c    Fri Jan 27 09:38:36 1989
  2655. --- d_menu.c    Thu May 11 10:35:34 1989
  2656. ***************
  2657. *** 50,53
  2658.       waddstr(dm_win, " Scroll Down");
  2659.   
  2660.       mvwattrstr(dm_win, 17, 14, A_BOLD, "<up>/<down>");
  2661.       waddstr(dm_win, " Page");
  2662.  
  2663. --- 50,56 -----
  2664.       waddstr(dm_win, " Scroll Down");
  2665.   
  2666. + #ifdef OLDCURSES
  2667. +     mvwattrstr(dm_win, 17, 14, A_BOLD, "U/N");
  2668. + #else /* OLDCURSES */
  2669.       mvwattrstr(dm_win, 17, 14, A_BOLD, "<up>/<down>");
  2670.   #endif /* OLDCURSES */
  2671. ***************
  2672. *** 51,54
  2673.   
  2674.       mvwattrstr(dm_win, 17, 14, A_BOLD, "<up>/<down>");
  2675.       waddstr(dm_win, " Page");
  2676.       mvwattrch(dm_win, 17, 34, A_BOLD, 'L');
  2677.  
  2678. --- 54,58 -----
  2679.   #else /* OLDCURSES */
  2680.       mvwattrstr(dm_win, 17, 14, A_BOLD, "<up>/<down>");
  2681. + #endif /* OLDCURSES */
  2682.       waddstr(dm_win, " Page");
  2683.       mvwattrch(dm_win, 17, 34, A_BOLD, 'L');
  2684. *** old/di_delay.c    Fri Jan 13 07:47:22 1989
  2685. --- di_delay.c    Wed Apr 26 08:35:19 1989
  2686. ***************
  2687. *** 50,54
  2688.       }
  2689.                       /* get the rdelay number */
  2690. !     wmove(dt_win, 6, 20);
  2691.       wrefresh(dt_win);
  2692.       if ((rdelay = get_num(dt_win, 3)) == -1) {
  2693.  
  2694. --- 50,54 -----
  2695.       }
  2696.                       /* get the rdelay number */
  2697. !     wmove(dt_win, 6, 22);
  2698.       wrefresh(dt_win);
  2699.       if ((rdelay = get_num(dt_win, 3)) == -1) {
  2700. *** old/di_win.c    Mon Jan 16 17:17:30 1989
  2701. --- di_win.c    Sat Apr 22 22:43:28 1989
  2702. ***************
  2703. *** 198,202
  2704.               else
  2705.                   write(fd, &cr, 1);
  2706. !             sleep(1);
  2707.           }
  2708.                       /* if we get here, no key was pressed */
  2709.  
  2710. --- 198,202 -----
  2711.               else
  2712.                   write(fd, &cr, 1);
  2713. !             sleep(2);
  2714.           }
  2715.                       /* if we get here, no key was pressed */
  2716. ***************
  2717. *** 257,260
  2718.                       dir->q_num[j] = dir->q_num[j+1];
  2719.                   dir->q_num[NUM_QUEUE-1] = -1;
  2720.                   break;
  2721.               case 'e':
  2722.  
  2723. --- 257,263 -----
  2724.                       dir->q_num[j] = dir->q_num[j+1];
  2725.                   dir->q_num[NUM_QUEUE-1] = -1;
  2726. +                 if (dir->q_num[i] == -1)
  2727. +                     i = 0;
  2728.                   break;
  2729.               case 'e':
  2730. *** old/getopt.c    Tue Oct 18 11:47:04 1988
  2731. --- getopt.c    Wed Apr 26 08:26:40 1989
  2732. ***************
  2733. *** 4,7
  2734.   
  2735.   #include <stdio.h>
  2736.   
  2737.   int optind = 1;
  2738.  
  2739. --- 4,8 -----
  2740.   
  2741.   #include <stdio.h>
  2742. + #include "config.h"
  2743.   
  2744.   int optind = 1;
  2745. *** old/help.c    Mon Jan 16 17:18:02 1989
  2746. --- help.c    Thu May 11 10:36:59 1989
  2747. ***************
  2748. *** 23,26
  2749.       horizontal(h_win, 2, 0, 80);
  2750.       mvwattrstr(h_win, 4, 0, A_BOLD, "       Major Functions          Utility Functions         File Functions\n\n");
  2751.       mvwprintw(h_win,  6,  2, "Dialing Directory.%4.4s-D  Program Info ....%4.4s-I  Send Files ....%4.4s-<up>", hot, hot, hot);
  2752.       mvwprintw(h_win,  7,  2, "Auto Redial ......%4.4s-R  Setup Screen ....%4.4s-S  Receive Files .%4.4s-<down>", hot, hot, hot);
  2753.  
  2754. --- 23,30 -----
  2755.       horizontal(h_win, 2, 0, 80);
  2756.       mvwattrstr(h_win, 4, 0, A_BOLD, "       Major Functions          Utility Functions         File Functions\n\n");
  2757. + #ifdef OLDCURSES
  2758. +     mvwprintw(h_win,  6,  2, "Dialing Directory.%4.4s-D  Program Info ....%4.4s-I  Send Files ....%4.4s-U", hot, hot, hot);
  2759. +     mvwprintw(h_win,  7,  2, "Auto Redial ......%4.4s-R  Setup Screen ....%4.4s-S  Receive Files .%4.4s-N", hot, hot, hot);
  2760. + #else /* OLDCURSES */
  2761.       mvwprintw(h_win,  6,  2, "Dialing Directory.%4.4s-D  Program Info ....%4.4s-I  Send Files ....%4.4s-<up>", hot, hot, hot);
  2762.       mvwprintw(h_win,  7,  2, "Auto Redial ......%4.4s-R  Setup Screen ....%4.4s-S  Receive Files .%4.4s-<down>", hot, hot, hot);
  2763. ***************
  2764. *** 25,28
  2765.       mvwprintw(h_win,  6,  2, "Dialing Directory.%4.4s-D  Program Info ....%4.4s-I  Send Files ....%4.4s-<up>", hot, hot, hot);
  2766.       mvwprintw(h_win,  7,  2, "Auto Redial ......%4.4s-R  Setup Screen ....%4.4s-S  Receive Files .%4.4s-<down>", hot, hot, hot);
  2767.       mvwprintw(h_win,  8,  2, "Keyboard Macros ..%4.4s-M  Change Directory.%4.4s-B  Pass Thru Mode.%4.4s-T", hot, hot, hot);
  2768.       mvwprintw(h_win,  9,  2, "Line Settings ....%4.4s-P  Clear Screen ....%4.4s-C  Directory .....%4.4s-F", hot, hot, hot);
  2769.  
  2770. --- 29,33 -----
  2771.       mvwprintw(h_win,  6,  2, "Dialing Directory.%4.4s-D  Program Info ....%4.4s-I  Send Files ....%4.4s-<up>", hot, hot, hot);
  2772.       mvwprintw(h_win,  7,  2, "Auto Redial ......%4.4s-R  Setup Screen ....%4.4s-S  Receive Files .%4.4s-<down>", hot, hot, hot);
  2773. + #endif /* OLDCURSES */
  2774.       mvwprintw(h_win,  8,  2, "Keyboard Macros ..%4.4s-M  Change Directory.%4.4s-B  Pass Thru Mode.%4.4s-T", hot, hot, hot);
  2775.       mvwprintw(h_win,  9,  2, "Line Settings ....%4.4s-P  Clear Screen ....%4.4s-C  Directory .....%4.4s-F", hot, hot, hot);
  2776. *** old/main.c    Tue Mar  7 11:18:10 1989
  2777. --- main.c    Thu May 11 11:54:47 1989
  2778. ***************
  2779. *** 15,18
  2780.    *    Patch #1    18 Feb 89
  2781.    *    Patch #2    11 Mar 89
  2782.    */
  2783.   
  2784.  
  2785. --- 15,19 -----
  2786.    *    Patch #1    18 Feb 89
  2787.    *    Patch #2    11 Mar 89
  2788. +  *    Patch #3    11 May 89
  2789.    */
  2790.   
  2791. ***************
  2792. *** 150,153
  2793.       cbreak();
  2794.       noecho();
  2795.   
  2796.   #ifdef OLDCURSES
  2797.  
  2798. --- 151,157 -----
  2799.       cbreak();
  2800.       noecho();
  2801. + #ifdef XENIX_3
  2802. +     raw();
  2803. + #endif /* XENIX_3 */
  2804.   
  2805.   #ifdef OLDCURSES
  2806. *** old/modem_break.c    Thu Jan 12 14:32:16 1989
  2807. --- modem_break.c    Wed May 10 12:18:47 1989
  2808. ***************
  2809. *** 5,8
  2810.   
  2811.   #include <stdio.h>
  2812.   #ifdef BSD
  2813.   #include <sgtty.h>
  2814.  
  2815. --- 5,12 -----
  2816.   
  2817.   #include <stdio.h>
  2818. + #ifdef XENIX_3
  2819. + #include <sys/types.h>
  2820. + #include <sys/ioctl.h>
  2821. + #endif /* XENIX_3 */
  2822.   #ifdef BSD
  2823.   #include <sgtty.h>
  2824. *** old/script.c    Mon Feb 20 15:32:06 1989
  2825. --- script.c    Sun Apr  2 12:21:17 1989
  2826. ***************
  2827. *** 138,143
  2828.               break;
  2829.       }
  2830. -                     /* wait for the zombie process */
  2831. -     wait(&sig_status);
  2832.   
  2833.       signal(SIGINT, istat);
  2834.  
  2835. --- 138,141 -----
  2836.               break;
  2837.       }
  2838.   
  2839.       signal(SIGINT, istat);
  2840. *** old/terminal.c    Mon Feb 20 15:32:08 1989
  2841. --- terminal.c    Tue May  2 09:29:35 1989
  2842. ***************
  2843. *** 394,397
  2844.   input_off()
  2845.   {
  2846.       if (pid != -1) {
  2847.           kill(pid, SIGTERM);
  2848.  
  2849. --- 394,399 -----
  2850.   input_off()
  2851.   {
  2852. +     SIG_TYPE (*cstat)();
  2853.       if (pid != -1) {
  2854.           /*
  2855. ***************
  2856. *** 395,398
  2857.   {
  2858.       if (pid != -1) {
  2859.           kill(pid, SIGTERM);
  2860.           pid = -1;
  2861.  
  2862. --- 397,404 -----
  2863.   
  2864.       if (pid != -1) {
  2865. +         /*
  2866. +          * This serves to periodically clean up the process table
  2867. +          */
  2868. +         cstat = signal(SIGCLD, SIG_IGN);
  2869.           kill(pid, SIGTERM);
  2870.           pid = -1;
  2871. ***************
  2872. *** 397,400
  2873.           kill(pid, SIGTERM);
  2874.           pid = -1;
  2875.       }
  2876.       return;
  2877.  
  2878. --- 403,407 -----
  2879.           kill(pid, SIGTERM);
  2880.           pid = -1;
  2881. +         signal(SIGCLD, cstat);
  2882.       }
  2883.       return;
  2884. *** old/tty_att.c    Thu Dec 29 13:24:52 1988
  2885. --- tty_att.c    Wed May 10 12:18:47 1989
  2886. ***************
  2887. *** 4,7
  2888.   
  2889.   #include <stdio.h>
  2890.   #include <termio.h>
  2891.   #include <fcntl.h>
  2892.  
  2893. --- 4,11 -----
  2894.   
  2895.   #include <stdio.h>
  2896. + #ifdef XENIX_3
  2897. + #include <sys/types.h>
  2898. + #include <sys/ioctl.h>
  2899. + #endif /* XENIX_3 */
  2900.   #include <termio.h>
  2901.   #include <fcntl.h>
  2902. *** old/vcs.c    Fri Jan 27 10:06:04 1989
  2903. --- vcs.c    Wed May 10 12:18:48 1989
  2904. ***************
  2905. *** 10,13
  2906.   #include <curses.h>
  2907.   #include <term.h>
  2908.   #endif /* OLDCURSES */
  2909.   
  2910.  
  2911. --- 10,15 -----
  2912.   #include <curses.h>
  2913.   #include <term.h>
  2914. + #else /* OLDCURSES */
  2915. + char tcbuf[1024];
  2916.   #endif /* OLDCURSES */
  2917.   
  2918. ***************
  2919. *** 188,192
  2920.   
  2921.   #ifdef OLDCURSES
  2922. !     char tcbuf[1024], tb[1024], *t, *cursor_home, *clr_eol, *clr_eos;
  2923.       char *clear_screen, *cursor_up, *cursor_down, *cursor_right;
  2924.       char *cursor_left, *cursor_address, *getenv(), *tgetstr(), *tgoto();
  2925.  
  2926. --- 190,194 -----
  2927.   
  2928.   #ifdef OLDCURSES
  2929. !     char tb[1024], *t, *cursor_home, *clr_eol, *clr_eos;
  2930.       char *clear_screen, *cursor_up, *cursor_down, *cursor_right;
  2931.       char *cursor_left, *cursor_address, *getenv(), *tgetstr(), *tgoto();
  2932. *** old/x_extrnl.c    Fri Feb  3 10:08:06 1989
  2933. --- x_extrnl.c    Sun Apr  2 12:21:19 1989
  2934. ***************
  2935. *** 118,123
  2936.               break;
  2937.       }
  2938. -                     /* wait for the zombie process */
  2939. -     wait(&sig_status);
  2940.   
  2941.       signal(SIGINT, istat);
  2942.  
  2943. --- 118,121 -----
  2944.               break;
  2945.       }
  2946.   
  2947.       signal(SIGINT, istat);
  2948.  
  2949.  
  2950.